我面临多个承诺中止一个承诺的问题。下面是片段
//Service
var deferedObject = $q.defer();
var promise = $http.get('/someUrl',{timeout: deferedObject.promise});
var onePromise = promise
var secondPromise = $http.get('/someUrl');
$q.all(['onePromise', 'secondPromise']).then(successResponse, failureResponse);
this.abort = function () {
deferredObject.resolve();
return deferredObject.promise;
}
//Controller
$scope.cancel = function() {
service.abort().then(success,function (response) {
});
}
如果我想中止承诺,它将不会中止如果我在 Parallel 中同时调用两个API但是如果我进行串行调用或者一个调用它就完全有效.Am我错过了什么?