i create one factory method which always returns undefined when retrieving value from controller. when i write log it values come perfectly but returns undefined.
.factory('GetLatLongFromAddress', ['$http', '$q', function ($http, $q) {
var LatnLong =
{
Latitude: 0.00,
Longitude: 0.00
}
return {
GetLatLong: function (address) {
var geocoder = new google.maps.Geocoder();
var address = address;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
LatnLong.Latitude = latitude;
LatnLong.Longitude = longitude;
console.log(LatnLong);
}
});
setTimeout(function () { }, 3000);
return LatnLong
},
}
}])
And myController in which i am calling is ;
$scope.returnValue=(JSON.stringify(GetLatLongFromAddress.GetLatLong("Address")));
So, can you help me in this.
Thank You.