AngularJS Using $q.all to handle multiple promises


You can use the $q.all function to call a .then method after an array of promises has been successfully resolved and fetch the data they resolved with.



 $ = []

    ]).then(function(responses) {
      $ = =>;

The above code runs $http.get 2 times for data in local json files, when both get method complete they resolve their associated promises, when all the promises in the array are resolved, the .then method starts with both promises data inside the responses array argument.

The data is then mapped so it could be shown on the template, we can then show


   <li ng-repeat="d in data">
         <li ng-repeat="item in d">{{}}: {{item.occupation}}</li>


  "name": "alice",
  "occupation": "manager"
}, {
  "name": "bob",
  "occupation": "developer"