I am trying to make an ajax call using $resource and load a datatable upon receiving the data from a server. But when I call a get() then I am getting $promise as undefined. I am using a factory to make the call. Here is my factory :
app.factory('getAllUsers', [ '$resource', function($resource) {
return $resource('URL', {}, {get : {method : 'GET'}});
}]);
And the controller :
app.controller('MyController',function($scope,$location,getAllUsers){
console.log("In controller");
getAllUsers.get().$promise.then(function(data) {
loadDatatable(data);
});
});
ERROR : getAllUsers.get().$promise is undefined
NOTE : I have included ngResource in my app and angular-resource.js in index.html too.