angular-访问多个http调用的数据-如何兑现承诺

angular-访问多个http调用的数据-如何兑现承诺,第1张

angular-访问多个http调用的数据-如何兑现承诺

您可以使用$ q的函数“ all”:

function giftControler ($scope, $http, $q) {  var names = $http.get("names.json"),      naughty = $http.get("naughty.json"),      nice = $http.get("nice.json");  $q.all([names, naughty,nice]).then(function(arrayOfResults) {       ... This callback would be called when all promised would be resolved    });

这样有点干净。

这是文档化的链接:http
://docs.angularjs.org/api/ng.$q



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5476604.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-12
下一篇 2022-12-12

发表评论

登录后才能评论

评论列表(0条)

保存