如何确定所有角度2分量均已渲染? [英] How to determine all the angular 2 components have been rendered?
问题描述
当所有Angular2组件完成渲染时是否会触发一个角度事件?
Is there an angular event which will be triggered when all the Angular2 components have finished rendering?
对于 jQuery
,我们可以使用
$(function(){ ... })
但是,使用Angular2,当触发 domready
事件时,html仅包含角度组件标签.在每个组件完成渲染后, domready
事件将再次触发&再次.
However, with Angular2, when the domready
event is triggered, the html contains angular component tags only. And after each component finished rendering, the domready
event will be triggered again & again.
我们需要的是在所有角度组件都完成渲染后的最终事件.
What we need is a final event when all the angular components have finished rendering.
推荐答案
Have you tried ngAfterViewInit on the root AppComponent
? I'm sure all the components have been rendered by then. This is a hook that angular calls after it creates all the component's child views.
这篇关于如何确定所有角度2分量均已渲染?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!