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!
you can do something
myApp.controller('fooCtrl', function($scope){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position){
$scope.$apply(function(){
$scope.position = position;
});
});
}
})
you need to do $scope.$apply to trigger the digest cycle when the geolocation arrives and to update all the watchers.