Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http Angular$q.all()只将第一个结果传递给then_Http_Angularjs_Promise - Fatal编程技术网

Http Angular$q.all()只将第一个结果传递给then

Http Angular$q.all()只将第一个结果传递给then,http,angularjs,promise,Http,Angularjs,Promise,正如标题中所述,当我用两个承诺调用$q.all()时,我只收到第一个结果。这就是我正在做的: $q.all(resouce1.getAll(), resource2.getAll()).then(function (res1, res2) { // only output one object which contains the result from the first promise // if I swap the two promise, the result is s

正如标题中所述,当我用两个承诺调用
$q.all()
时,我只收到第一个结果。这就是我正在做的:

$q.all(resouce1.getAll(), resource2.getAll()).then(function (res1, res2) {
    // only output one object which contains the result from the first promise
    // if I swap the two promise, the result is still the first one.
    // can't really get both results at the same time
    console.log(arguments);     
});
感谢您的帮助

$q.all([resouce1.getAll(), resource2.getAll()]).then(function (res) {
    console.log(res);     
});
all
接受一个数组或承诺哈希,然后使用单个数组结果调用函数

all
接受一个数组或承诺哈希,然后使用单个数组结果调用函数。

:)。令人惊叹的。我错过了传递数组的要点。非常感谢你,伙计。令人惊叹的。我错过了传递数组的要点。非常感谢你,伙计。