最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to determine all the angular 2 components have been rendered? - Stack Overflow

programmeradmin1浏览0评论

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!!

发布评论

评论列表(0)

  1. 暂无评论