2
我有一个问题,等待我的forEach循环,里面有一个承诺,完成。我找不到可以让脚本等待它完成的解决方案。我不能使someFunction异步。等待每个承诺内完成
makeTree: function (arr) {
arr.forEach(function (resource) {
someModule.someFunction(resource).then(function() { //a Promise
//do something with the resource that has been modified with someFunction
})
});
// do something after the loop finishes
}
你使用的是angularjs吗? –