Angularjs - Accessing a service variable

Asked

Viewed 39 times

1

How do I access the variable LatLng in the application?

$http({
       method: 'POST',
       url: './database/getCep.php'
}).then(function successCallback(response) {
       var LatLng = $scope.get_cep = response.data;
       console.log(LatLng);
});
  • You probably need to put it in the scope, but show us what you want to do more clearly.

1 answer

1

Friend, for you to access this variable you will have to go through the function of then. It would be interesting to create a function to access it, as a getLatLng().

Would that way:

$http({
       method: 'POST',
       url: './database/getCep.php'
}).then(function successCallback(response) {
       var LatLng = $scope.get_cep = response.data;
       return LatLng;
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.