OK, suppose I have n an array of XHR requests: How can I be sure to call Thank you for your help! From angle to docs: $ http API $ q Based on service deferred / wired API. So it is possible to use the method that takes an array of promises and: combines many promises in the same promise, all the promises Solution is resolved The implementation code is:
var promises = []; Var AllResults = []; $ Scope.requests = [["Yuri": "http: // foo / bar / action1", "name": "action1"}, {"yuri": "http: // bar / foo / action2" "Name": "action2"}, {...}, {...}, {...}]; Var ParseMyResultsArray = function () {console.log (AllResults); // ...}; Angular.forEach ($ scope.requests, function (request) {var promise = $ http.get (request.uri); promises.push (promise);}); Angular.forEach (Promise, Work (Promise) {Promise. Then (Work (Results) {AllResults.push (Results);}}}}; // Then, when all the promises are resolved ... ParseMyResultsArray ();
ParseMyResultsArray () when my promises to know the size of my
requests Is it sorted without a > array?
$ q.all (promises). Then (work () (/ * all promises are solved * /});
No comments:
Post a Comment