Angular 2 execute script after template render

后端 未结 4 1470
傲寒
傲寒 2021-01-31 13:32

So I have this slider component that use materializecss javascript. So after it\'s rendered, I need to execute

$(document).ready(function(){
    $(\'body\').on(\         


        
4条回答
  •  心在旅途
    2021-01-31 14:11

    ngAfterViewInit() of AppComponent is a lifecycle callback Angular calls after the root component and it's children have been rendered and it should fit for your purpose.

    See also https://angular.io/guide/lifecycle-hooks

提交回复
热议问题