如何使用$q.all的AngularJS哈希选项?
发布时间:2020-12-17 07:19:26 所属栏目:安全 来源:网络整理
导读:我环顾四周,一无所获,解释如何使用它.文件说明: 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 r
我环顾四周,一无所获,解释如何使用它.文件说明:
但没有例子. 有没有人有任何使用密钥/哈希方法的例子?
似乎没有很多这样的例子,但它应该像这样工作:
// 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]; }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |