Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,

I got struck in one concept for long time, somehow able to complete the task using alternative methods but still i would like to know the exact procedure to do it. so here we go.

Problem Code :

JavaScript
var values=[a,b,c,d];

angular.forEach(values,function(value,key){

console.log('loop '+value+'Started');
var status=loading;
console.log('loading',value);
someAsyncMethod().then(function(status){   
console.log('status of '+value + 'is '+status);  // loop doesn't wait for this code to complete
},function(error){
console.log('error occured for value'+ error);
})
console.log('loop '+value+'ended'); // jumps to this code directly and continues the loop
})




Im not that good in syntax so please give me some suggestion on it.
Posted
Comments
phil.o 15-Sep-15 3:23am    
You did not describe an actual problem, nor did you ask an actual question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900