$timeout is normally what is used to run something after a digest cycle (and after the browser renders).
$timeout
will cause another digest cycle to be executed after the function is executed. If your trigger
does not affect anything Angular, you can set the invokeApply
argument to false
to avoid running another digest cycle.
If you want your callback to run before the browser renders: If code is queued using $evalAsync
from a directive, it should run after the DOM has been manipulated by Angular, but before the browser renders. However, if code is queued using $evalAsync
from a controller, it will run before the DOM has been manipulated by Angular (and before the browser renders). See also https://stackoverflow.com/a/17303759/215945.