Monday, 15 April 2013

http - Angularjs for loop promises callback -


I was thinking that there is a possibility to receive a callback at the end of a series of requests. I am enclosing an example code so you can better understand:

 for  (var i = 0; i & lt; $ scope.array.length; i ++) {factory. GetX ($ radius. Array [i] .ad) .vivet (function (_pressance) {/ call function if this is the last request for loop).). Panic (function (_ar) {$ scope.displayAlert (_RR}}}  

In a factory object, I have a $ http.get () function Thank you!

If you want to make a callback, when all requests are completed, then all of you You can save promises that are made in an array and make a general promise with var allRequests = $ q.all (arrayOfPromises)

, then you AllRequests.then (callback) to apply your callback


No comments:

Post a Comment