Is there a way to access the localeData value outside of the function below? I am able to print it inside the function, but not sure how to access it outside. I have tried few things but nothing seems to work.
$http.post(SERVER_URL + 'getLocaleData').success(function(localeData) {
console.log(localeData);
}).error(function(err) {
alert('warning', err.message);
});
//I need to grab the value here.
console.log(localeData);
UPDATE
I actually want to achieve this:
app.factory('customLoader', function($http, $q, SERVER_URL) {
return function(options) {
var deferred = $q.defer();
// using $http, $q and key to load localization files
$http.post(SERVER_URL + 'getLocaleData').success(function(localeData) {
//working with localData here
}).error(function(err) {
alert('warning', err.message);
});
deferred.resolve(localeData);
return deferred.promise;
};
});
This is my goal - ultimately, I aim to send the localeData.