Angular2 Download component of external js lib file

I have a component that uses javascript library. For now, I'm just using system.js to load dependencies

public ngOnInit() { System.import('lib').then(() => this.createControl()); } 

However, this delay in initializing the component causes a problem with another consuming component. In essence, the createControl function works too late.

Is it possible to delay initialization of the entire component with angular until all dependencies are loaded?

+5
source share
1 answer

Is it possible to delay initialization of the entire component using angular until all dependencies are loaded

Just add lib as a file dependency. Put this at the top of the file containing the component:

 import * as lib from "lib" 

This will effectively load the "lib" before loading the application.

0
source

Source: https://habr.com/ru/post/1244844/


All Articles