6

I would like to execute a piece of code after every $digest loop, after the DOM has been constructed, but before the render. I want this on every $apply, not just the ones after linking/compiling. Where do I add my code?

I am not going to provide my particular use case because I would like to know how to do this in general. If you would like to help me with my particular problem, I have a separate question: Resize IFRAME to Remove Scrollbars

4
  • 1
    you can do $rootScope.$watch(function(){ ... }). The logic in the fn will be called every $digest loop Commented Jul 26, 2013 at 18:00
  • @IanHaggerty It works! Thanks! Would you like to post that as an answer? Commented Jul 26, 2013 at 18:04
  • @IanHaggerty This runs once for each cycle of the loop, right? Commented Jul 26, 2013 at 18:05
  • Don't thank me, thank thinkster :) thinkster.io/pick/51dc70a1fc30e44f96000001/digest Commented Jul 26, 2013 at 18:07

1 Answer 1

16

you can do $rootScope.$watch(function(){ ... }). The logic in the fn will be called every $digest loop

Sign up to request clarification or add additional context in comments.

1 Comment

I found it's important to make sure you don't return something weird or you can get infinite digests happening. return true; will fix that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.