I don't understand why I can not take the value from a function and to display it in another in angular. My code:
$scope.getLatitudeLongitude = function(address) {
var geocoder = new google.maps.Geocoder();
$scope.latLng = [];
geocoder.geocode( { "address": address }, function(results, status) {
if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
var location = results[0].geometry.location,
lat = location.lat(),
lng = location.lng();
$scope.latLng.push(lat,lng);
return $scope.latLng;
}
});
};
$scope.save = function () {
$scope.address = $scope.getAddress();
$scope.getLatitudeLongitude($scope.address).then(function(){
console.log($scope.latLng);
})
}
Any ideas?