AngryJS AngryJS - 1 year ago 129
AngularJS Question

How can I use HTML5 geolocation in angularjs

How can I use HTML5 geolocation in angularjs? I can get it using HTML5; but how can I pass it to angularjs scope in controller? any sample jsfiddle will save my day!

Answer Source

you can do something

myApp.controller('fooCtrl', function($scope){
  if (navigator.geolocation) {
        $scope.position = position;

you need to do $scope.$apply to trigger the digest cycle when the geolocation arrives and to update all the watchers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download