My understanding of $$ postDigest is that it has the ability to trigger a callback after the current digest cycle is completed - without having to create a new digest cycle in the process.
However, does this mean that all DOM effects caused by the current digest cycle are visible to the callback in $$ postDigest.
Given the pseudo code below:
//some code affecting the width of an element and triggering a digest loop myModel.width = 10; //bound back to dom element with id = 'myId' $$postDigest(function(){ //some callback running after the most recent digest loop //gets the width of a DOM element by reading the value directly from the DOM element //that was changed in the previous digest loop var width = $('#myId').width(); //Will width always be 10 here? });
Assume that the bound value in the current digest cycle changes the width of the DOM element. Then in $$ postDigest I run a callback with some legacy code that directly reads the changed width from the DOM element. Is it safe to read the value from the DOM element in $$ postDigest, since it should happen after the digest cycle is complete. In other words, should the browser be executed with a digest loop effect by the time $$ postDigest is launched?
I am not a fan of this template, but should integrate with some angular code
source share