Hi I’m an Ionic newbie and I started this morning working with ngCordova but i’m finding problems the controller don’t work when I add $cordovaGeoLocation to it
angular.module('starter', ['ionic','ngCordova'])
.run(function($ionicPlatform, $cordovaGeoLocation) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller(‘MyFirstController’, function($scope){
$scope.currentCoords = {“Longtitude”: “1.59995”, “Latitude”: “15.09965”};
$scope.refresh = function()
{
var options = { timeout: 10000, enableHighAccuracy:false};
$cordovaGeoLocation.getCurrentPosition(options).then(
function(position){
var Longtitude = position.coords.longitude;
var Latitude = position.coords.getLatitude;
$scope.currentCoords = {“Longtitude”: Longtitude, “Latitude”: Latitude};
},
function(err){
console.log(err);
});
};
});
Thank you for the response . The ngCordova js files are installed with : bower install ngCordova also org.apache.cordova.geolocation
but the GPS is not turned on can you tell me how can i do it
It’s ok i configured it and i took a look at permissions at Android Manifest File and the Address Fine Location authorization is set …
I Think that is a problem with ngCordova because the controller don’t provide data to the view, i see blanked data like this : {{ parameter.value }} even before i click on the button to tell the controller to provide the data (Longtitude and Latitude)