Example is misleading
Closed this issue · 2 comments
facultymatt commented
The example provided in the readme is misleading and doesn't work as the user might expect:
angular
.module('myApp', ['ngGeolocation'])
.controller('geolocCtrl', ['$geolocation', '$scope', function($geolocation, $scope) {
$scope.myPosition = $geolocation.getCurrentPosition({
timeout: 60000
});
}]);
In the above example, $scope.myPosition
doesn't contain the position. Instead it contains a promise. To access the position, the user needs to use the then
callback, like this:
angular
.module('myApp', ['ngGeolocation'])
.controller('geolocCtrl', ['$geolocation', '$scope', function($geolocation, $scope) {
$geolocation.getCurrentPosition({
timeout: 60000
}).then(function(position) {
$scope.myPosition = position;
});
}]);
This is even how you use it in your tests: https://github.com/ninjatronic/ngGeolocation/blob/master/ngGeolocation.test.js#L53-L55
ninjatronic commented
Thanks for the issue. A PR is welcome if you have the time :)
ninjatronic commented
Fixed in 0d25b61