我环顾四周,一无所获,解释如何使用它.文件说明:
Returns a single promise that will be resolved with an array/hash of
values,each value corresponding to the promise at the same index/key
in the promises array/hash. If any of the promises is resolved with a
rejection,this resulting promise will be rejected with the same
rejection value.
但没有例子.
有没有人有任何使用密钥/哈希方法的例子?
似乎没有很多这样的例子,但它应该像这样工作:
原文链接:https://www.f2er.com/angularjs/141625.html// as an object $q.all({ one: $http.get('/url1'),two: $http.get('/url2') }).then(function (results) { var data1 = results.one; var data2 = results.two; }); // as an array $q.all([ $http.get('/url1'),$http.get('/url2') ]).then(function (results) { var data1 = results[0]; var data2 = results[1]; });