在DOM渲染之前执行每个摘要循环后的函数

时间:2020-12-13 01:46:52

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?

我想在每个$ digest循环之后,在构造DOM之后但在渲染之前执行一段代码。我希望在每个$ apply上都有这个,而不仅仅是链接/编译后的那个。我在哪里添加我的代码?

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

我不打算提供我的特定用例,因为我想知道如何做到这一点。如果您想帮助我解决我的特定问题,我有一个单独的问题:调整IFRAME大小以删除滚动条

1 个解决方案

#1


16  

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

你可以做$ rootScope。$ watch(function(){...})。每个$ digest循环都会调用fn中的逻辑

#1


16  

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

你可以做$ rootScope。$ watch(function(){...})。每个$ digest循环都会调用fn中的逻辑