I am managing two services - one to make an ajax call and the other to process the data received from the call. However, I am facing an issue with updating the data before returning it to the controller. Below is the code snippet:
angular.module("Data", []).service("DataService", function ($http) {
return {
Data:
function (url, callback) {
$http.get(url).success(callback);
},
}
})
angular.module("Home", ["Data"]).service("HomeService", function (DataService) {
return
{
Dataw3:
DataService.Data('http://www.w3schools.com/angular/customers.php', function (results) {
return results.records
});
}
})
angular.module("Home").controller("HomeCntrl", function ($scope, HomeService) {
console.log(DataService.Dataw3)
})