I have a service like
app.factory(\'geolocation\', function ($rootScope, cordovaReady) {
return {
getCurrentPosition: cordovaReady(function (onSu
Just call your onSuccess method in the service instead of handling the result there.
getCurrentCity: function (onSuccess, onError) {
this.getCurrentPosition(function (position) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode(options, onSuccess);
});
}
And in your controller, parse the results and assign the city:
function MainCtrl($scope, geolocation) {
geolocation.getCurrentCity(function(results, status){
// Parse results for the city - not sure what that object looks like
$scope.city = results.city;
});
};