Utilizing a service, I am retrieving data from the server through this function:
LeadsSrv.async().then(function (d) {
results = d.data;
});
The goal is to access the results outside of this function and assign them to the scope like so:
$scope.All_Leads = results;
This is the server function employed for this task:
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;
});
What steps should I take to accomplish this?