After the angular end of all the clock cycles, there is no way to call the custom function in angular.
Needs I have multiple clockworks within my controller. Now I want to execute a function when all clock functions are executed by angular
There are several ways to register callback after a digest is completed.
using the $$ postDigest
: $ radius Removes $$ postDigest current
. $ digest
after the cycle is completed
Although it runs only once after the next digest cycle. This code is based on sample to run after each digest cycle running with $ watch
var hasRegistered = false; $ Scope $ Watch (function () {if (hasRegistered) return; hasRegistered = true; $ radius. $$ postDigest (function () {hasRegistered = false; fn ();});}); During a digest cycle, $ watch
may trigger multiple times so that we have a flag to prevent $$ hasRegistered
Use Post Dangerous
Callback to be registered multiple times Note: $$ PostDocument will not trigger another Digest Cycle. Then any change in the $$ postDigest
inside the $ range
will not be visible in the dom. $$
means this is a personal function that is in angular, so the function is not stable and can change in the future.
It moves after the present digestion cycle is complete. Note: The third argument is set to false to prevent another digest cycle trigger.
No comments:
Post a Comment