$ scope. $ evalAsync vs $ scope. $ applyAsync

What is the difference between $ evalAsync and $ applyAsync? I understand that when I use $ evalAsync from the directive, the expression will be evaluated before the browser displays it.

So, as an example, if I wanted to scroll to a certain position on the page, but not show the transition to that place, I could use this to scroll to a position, and since it fires before the browser displays, this visual error will disappear.

However, what is the purpose of applyAsync? When is it a good idea to use one over the other?

+7
dom angularjs
source share
2 answers

$ evalAsync ()

will be executed in the current digest

$ applyAsync ()

in the planned.

If you need details: Ben Nadel or here

+5
source share

Here is what I used $ applyAsync for. Basically, I use this as a safe $ apply. Do you know this annoying mistake when you try to call a digest when it is already running? If you use $ applyAsync, you will get another digest, but this will happen when the current digest cycle ends.

$ applyAsync is also cool, since you can load a bunch of callbacks to run in the following summary.

0
source share

All Articles