Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Lazy-load PIC Component
private async __loadComponent(): Promise<any>
{
let factory: ComponentFactory<IPointInCircle>;
if (this.picContainer) {
this.picContainer.clear();
}
// lazy-load the required component based on the algorithm id
switch (this.algorithm)
{
case 1:
const {Pic1Component} = await import('./components/point-in-circle-1/pic-1.component');
factory = this._compFactoryResolver.resolveComponentFactory(Pic1Component);
this.ComponentInstance = this.picContainer.createComponent(factory, null, this._injector);
this.render = RenderTargetEnum.CANVAS;
break;
case 2:
const {Pic2Component} = await import('./components/point-in-circle-2/pic-2.component');
factory = this._compFactoryResolver.resolveComponentFactory(Pic2Component);
this.ComponentInstance = this.picContainer.createComponent(factory, null, this._injector);
this.render = RenderTargetEnum.SVG;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment