admin管理员组

文章数量:1414628

Is there an angular event which will be triggered when all the Angular2 ponents have finished rendering?

For jQuery, we can use

$(function(){ ... })

However, with Angular2, when the domready event is triggered, the html contains angular ponent tags only. And after each ponent finished rendering, the domready event will be triggered again & again.

What we need is a final event when all the angular ponents have finished rendering.

Is there an angular event which will be triggered when all the Angular2 ponents have finished rendering?

For jQuery, we can use

$(function(){ ... })

However, with Angular2, when the domready event is triggered, the html contains angular ponent tags only. And after each ponent finished rendering, the domready event will be triggered again & again.

What we need is a final event when all the angular ponents have finished rendering.

Share Improve this question edited Nov 2, 2016 at 14:59 Poul Kruijt 72.1k12 gold badges152 silver badges151 bronze badges asked Nov 2, 2016 at 14:52 mind1nmind1n 1,2063 gold badges17 silver badges34 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Have you tried ngAfterViewInit on the root AppComponent? I'm sure all the ponents have been rendered by then. This is a hook that angular calls after it creates all the ponent's child views.

you may check ngAfterViewInit applied on the root ponent.

ngAfterViewInit Respond after Angular initializes the ponent's views and child views. Called once after the first ngAfterContentChecked.

Read more about it here.

Hope this helps!!

本文标签: javascriptHow to determine all the angular 2 components have been renderedStack Overflow