Skip to content

Commit b8472b5

Browse files
author
Artemy Tregubenko
committed
feat(ngResource): Add $abort method to objects returned by $resource "class" actions
`$resource` "class" actions delegate to `$http` in a fashion that does not allow to pass timeout promise to individual requests. Hence these individual requests can not be cancelled. This patch adds $abort method to the object returned by `$resource` "class" actions. Closes angular#5612
1 parent 37d1e5e commit b8472b5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/ngResource/resource.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,9 @@ angular.module('ngResource', ['ng']).
506506
// If parameters do not contain `timeout` which is a promise, create it,
507507
// so that later this call can be aborted by resolving this promise
508508
var timeout = httpConfig.timeout;
509+
var timeoutDeferred;
509510
if (!timeout || !timeout.then) {
510-
var timeoutDeferred = $q.defer();
511+
timeoutDeferred = $q.defer();
511512
httpConfig.timeout = timeoutDeferred.promise;
512513
// If timeout is specified in milliseconds, use it to abort via promise
513514
if (timeout) $timeout(timeoutDeferred.resolve, timeout);

0 commit comments

Comments
 (0)