I am getting data from the server with a service which is being called in this function:
LeadsSrv.async().then(function (d) {
results = d.data;
});
I want to access the results outside of this function and then assign it to the scope, like this:
$scope.All_Leads = results;
Here is the server function:
LeadApp.service('LeadsSrv', function ($http) {
var all = {
async: function() {
var promise = $http({
url: '../app/Data.php',
method: "POST",
params: { req_id: 'leads_list', user_id: 1 }
}).then(function (response) {
return response;
});
return promise;
}
};
return all;
});
How can i achieve this?