I'm doing some tricky things on a particular app that involves lots of UI
manipulation. I've had to use JQuery for some of it as there just is no way
around it that I can see. Dealing with responsive images and SVG elements
so yeah...
Is there a way for Angular to return a promise for a digest cycle? I want
to be able to run some UI logic after Angular has run the most recent
digest cycle. For example, user clicks button (via ngClick) which
internally fires a digest since a scope variable is modified within the
click event handler. After the digest, I want to run some JQuery code that
depends on the fact that the digest cycle completed which updated a
variable on some elements.
Currently, I'm doing this with setTimeout, however, it's not the best
Example Pseudocode:
<div ng-style="divStyle"></div>
<button ng-click="isCollapsed = !isCollapsed" />
link(){
scope.$watch("isCollapsed", (isCollapsed)=> {
$scope.divStyle = isCollapsed ? {} : {width: $(document).innerWidth() - 400
};
setTimeout(()=>{
//execute logic after layout has reflowed (i.e. update elements using
jquery based on now layout dimensions)
}, 25); //permit 25 ms for digest cycle and layout reflow
});
}
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.