Friday, June 13, 2014

Angular.js: wait for multiple calls to complete

In Angular.js I had a controller where I had to execute an action after multiple service calls are completed. Thanks to the $q promise library integrated in Angular.js, this is easy to achieve:

Both getApplications() and getEnvironments() return a Promise. By wrapping them in a call to $q.all(), the parent Promise is only resolved after both wrapped Promised are completed.

No comments: