I am making a series of http requests and I need to file the results into a list object when they return. I'm using angular promises.
Because the promises only resolve after the for loop is finished, they all get filed into the last index of list.
for (var i = 0;i < list.length; i+=1) {
Promise.do(action).then(function(result) {
list[i] //i is always at last index because the for loop has already completed
}
}