When I save my data using angular service factory, how do I handle the timeout event, lets say if the internet connection is unstable, now I end up with a loading screen infinitely, so I want to set timeout after few seconds if the response is not received, my rest service looks like this:
.factory('Deal', [ '$resource', function($resource) {
return $resource("/deals/:id/:action.json", {
id : "@id",
action : "@action"
}, {
query : {
method : "GET",
isArray : false
},
update : {
method : "POST",
params : {
action : 'update'
}
}
});
} ])
And this is how I call the save method:
Deal
.save(
$scope.deal,
function(data) {
},
function(err) {
});