The location for my ionic app in angularjs is not loading the location. It sometimes gets stored into the model and shows up, but when I do a console.log it never shows up. Here is a codepen of the app
http://codepen.io/anon/pen/niKuI?editors=101
<link href="http://code.ionicframework.com/1.0.0-beta.11/css/ionic.css" rel="stylesheet">
<script src="http://code.ionicframework.com/1.0.0-beta.11/js/ionic.bundle.js"></script>
thanks
The console.log is being called before the getCurrentPosition
method completes. I changed the call in $scope.searchRest
to be as below and it worked correctly and logged out the url to the console.
navigator.geolocation.getCurrentPosition(function(position) {
$scope.$apply(function () {
$scope.url = $scope.url + '&location=' +
position.coords.latitude + ',' +
position.coords.longitude;
console.log($scope.url);
)};
}, function(error) {
alert(error);
});
I hope this helps.