0

I have a matter which I can not find a suitable solution.

In Angular.js, I have a "List of List" where the first top list contains a second list of items, where each item need to run a $http GET.

I want this:

Task 10 - Task 11 - Task 12 --> run in parallel
|
Task 20 --> run in parallel after Task 1- are finished
|
Task 30 - Task 31 --> run in parallel after Task 2- are finished

I tried to use angular.forEach inside angular.forEach but all the tasks are run in parallel.

I don't know how to handle this.

  • asynchronous is **not** parallel. But you are right that they don't run in sync. To do that you would want to resolve them with `$q.all( list_of_promises )`, which can accept a list of your promises that you can populate in a for loop. For links/dependancies - just chain then within each other's resolve – Aleksey Solovey Apr 24 '18 at 15:18
  • but as my first list is built dynamically, I don't know how to chains the items ? – Jean-Philippe Apr 24 '18 at 15:43
  • [chain promises*](https://stackoverflow.com/questions/31366323/chain-multiple-promises-in-angularjs?rq=1) – Aleksey Solovey Apr 24 '18 at 15:46
  • I found my way with this post https://stackoverflow.com/questions/28983424/make-angular-foreach-wait-for-promise-after-going-to-next-object Thanks for showing me the right way, I didn't know I could dynamically chains promises !! – Jean-Philippe Apr 24 '18 at 16:22

0 Answers0