【发布时间】:2016-06-22 15:56:15
【问题描述】:
我有这个:
var j = 0;
// myList.length = 3
while(j < self.myList.length - 1){
$http.post('myURL', self.myList[j].code).then(
function(response){
self.myList[j].plop = response.data;
}, function(){
// error
}
).then(
function(){
// with this j++, my web page is freezing
// j++;
}
);
// with this j++, only the 3rd element of myList have a "plop" element
//j++;
}
我的问题在于“j++”的 cmets :)。 如果我删除循环并硬编码第 3 步,它就可以工作。但我不知道如何用循环解决这个问题。你有想法吗 ?谢谢
【问题讨论】:
标签: angularjs synchronization promise http-post