内部に約束を持っている私のforEachループを待つことに問題があります。私は、スクリプトが終了するのを待つソリューションを見つけることができません。私はsomeFunctionを非同期にすることはできません。代わりにforEach()
使用map()
の内部が約束してforEachを待つ
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
}
anglejsを使用していますか? –