$q.all([firstPromise, secondPromise])
.then(successHandler1, errorHandler1)
.then(successHandler2, errorHandler2);
调用errorHandler1后会调用successHandler2吗?
答案 0 :(得分:1)
如果值从拒绝回调返回,则将执行成功回调,如果抛出错误,则将执行错误回调。
var app = angular.module('myApp', [])
app.controller('myController', function ($q) {
$q(function (resolve, reject) {
reject('1');
})
.then(
function(resolve) {
console.log('resolve 1');
return 'resolve 1';
},
function(reject) {
console.log('reject 1');
throw 'reject 1'
})
.then(
function(resolve) {
console.log('resolve 2');
},
function(reject) {
console.log('reject 2');
return 'reject 2'
})
.then(
function(resolve) {
console.log('resolve 3');
},
function(reject) {
console.log('reject 3');
})
})
http://plnkr.co/edit/k2UprgZd0J4RP8PtDye2?p=preview
控制台:
拒绝1
拒绝2
解决3
答案 1 :(得分:0)
电话的顺序是:
successHandler1然后是successHandler2 要么 errorHandler1是errorHandler2