So I\'m using angularjs restful service $resource and I\'m calling $save function. However, the error callback I pass to it is not being called. The server is sending a 41
I'm copying from the ngResource documentation:
The action methods on the class object or instance object can be invoked with the following parameters:
- HTTP GET "class" actions: Resource.action([parameters], [success], [error])
- non-GET "class" actions: Resource.action([parameters], postData, [success], [error])
- non-GET instance actions: instance.$action([parameters], [success], [error])
Success callback is called with (value, responseHeaders) arguments. Error callback is called with (httpResponse) argument.
$save
is considered as a non-GET "class" action, so you must to use an extra postData
parameter. Using the same question example, this should work:
modalScope.submit = function(user) {
user.$save( {}, {}, function(data,headers) {
// do the success case
}, function(response) {
// do the error case
});
};
Keep an eye on the error callback, compared with the example, is calling with just one argument, which brings all the http response.