[Related philosophical debate about just sleeping it out at programmers.se]
Angualr is not guaranteed to update the DOM completely in the event handler for the AJAX completion (especially if third-party directives are involved), so most of the solutions floating online about using $http interceptors
are incomplete.
The answer to a very similar question "Wait for angular to finish updating the DOM", suggests using $timeout
. However, its source suggests it uses the $browser.defer
mechanism so can actually be executed in any order with other deferred DOM manipulation.
I found $browser.notifyWhenNoOutstandingRequests
internal method which happens after all the deferred
stuff, but the test is still unstable after waiting for that. I guess I should wait for AJAX to complete first or is there something else I've missed?