I've got a weird error in angularjs. I've used $resource module in angularjs to make rest requests by registering this service
$provide.service("CustomerService", ['$resource', function ($resource) {
return $resource('/com/caspco/customers/:url:id', {}, {
query: { method: 'GET', isArray: true, params: {id: '@id'}},
find: { method: 'POST', isArray: true ,params:{url:'search'}},
.......... other actions ..........
});
}]);
in the rest server side I have a search method with the above url of find
action that returns a json array. when I what to call find
action by this way in the controller :
service.$find().$promise.$then(function (res) {
console.log("resource is" + res);
}, function (error) {
console.log("error");
});
It raises
TypeError: (anonymous function) angular.js:2070
(anonymous function) angular.js:1516
k.$apply angular.js:2575
(anonymous function) angular.js:4323
o.event.dispatch jquery.js:3
r.handle