javascript - Does it make sense to wrap jQuery code in `document.ready()` inside your Angular 2 components functions -
i want sure if angular component code running. means @ moment dom
should ready. example:: typescript
export class somecomponent{ constructor(){ $('body').do(); } }
or
export class somecomponent{ constructor(){ $(document).ready(function(){ $('body').do(); } } }
add code ngafterviewinit()
of root component appcomponent
. when lifecycle methos called, can sure dom ready. document.ready
event have been sent way before lifecycle method called.
see https://angular.io/docs/js/latest/api/core/afterviewinit-interface.html
Comments
Post a Comment