The million dollar question most of the AngularJS users(devs) end up asking is
- How to wait for angular digest cycle to be completed? or in simple terms
- How to wait for browser to complete rendering the view with angular bindings?
AngularJS does not raise any event to notify this. The suggested simple solution is to use $timeout to queue your work to be run after current digest cycle (also waits for DOM renedering to be completed by the browser).
1 2 3
The above solution works only for views which don’t have ng-include or directives with template url. In this case you have to wait for all the templates to be loaded(async) and then run your code. This can be achived by waiting for $http.pendingRequests to be zero. The enhanced solution is
1 2 3 4 5 6 7 8
Hopefully AngularJS will come up with a easier solution in future releases.