AngularJS - Access a variable from a service

1

How do I access the LatLng variable in the application?

$http({
       method: 'POST',
       url: './database/getCep.php'
}).then(function successCallback(response) {
       var LatLng = $scope.get_cep = response.data;
       console.log(LatLng);
});
    
asked by anonymous 27.11.2017 / 20:14

1 answer

1

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

It would look like this:

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