Angular2 equivalent of $document.ready()

前端 未结 6 990
清歌不尽
清歌不尽 2020-12-01 03:48

Simple question, I hope.

I want to run a script when the Angular2 equivalent of $document.ready() is fired. What is the best way to achieve this?

I\'ve tried

6条回答
  •  -上瘾入骨i
    2020-12-01 04:48

    the accepted answer is not correct, and it makes no sens to accept it considering the question

    ngAfterViewInit will trigger when the DOM is ready

    whine ngOnInit will trigger when the page component is only starting to be created

提交回复
热议问题