Angular : Load An Extrenal Js File Script After Component View Loaded
Under my Anglar 5 app, I have a js script file which I want to load dynamically after the loading of my component view, this is because my script acts with my component template,
Solution 1:
Use the AfterContentChecked
LifeCycle.
AfterContent hooks AfterContent hooks are similar to the AfterView hooks. The key difference is in the child component.
-The AfterView hooks concern ViewChildren, the child components whose element tags appear within the component's template.
-The AfterContent hooks concern ContentChildren, the child components that Angular projected into the component.
Another approach:
I solved this a long time ago with:
ngAfterViewInit() {
setTimeout(() => {
doSomething();
}, 0);
}
Post a Comment for "Angular : Load An Extrenal Js File Script After Component View Loaded"