Objective: a simplyfied way to generate dynamic angular components, that can also be used as plain DOM.
Intall the @ciag/component-factory via NPM
npm i @ciag/component-factory
app.module.ts
import { ComponentFactoryModule } from '@ciag/component-factory';
@NgModule({
//...
imports: [
//...
ComponentFactoryModule
],
//...
})
export class AppModule { }
my.component.ts
import { Component, OnInit } from '@angular/core';
import { ComponentFactoryService } from '@ciag/component-factory';
@Component({
//...
})
export class AppComponent implements OnInit {
//...
constructor(private componentFactoryService: ComponentFactoryService) { }
ngOnInit() {
this.componentFactoryService.create(MyComponent)
}
}