I have this service that loads data..
angular.module('App').service('daysService', ['$http','$q',function($http,$q) {
var days = [];
return {
loadDay: function() {
$http({
method: 'get',
url: '/app/days/list/',
}).success(function(data) {
days.push(data);
return days;
}).error(function (data) {
console.log('Error checking server.');
});
}
};
}]);
than in the controller i call the service
daysService.loadDay.then(function(data) {
alert(data)
});
But i'm getting this error TypeError: daysService.loadDay.then is not a function
Any suggestion?
servicetofactoryloadDay()instead ofloadDay? Considering its a function...serviceis actually how you use afactory, if you were using theserviceproperly then you would have declaredloadDaylike this:this.loadDay = function () {}with out returning anythingloadDayfunction$httpalso