I have an app component in my angular application.
@Component({
selector: my-container',
template: `<div [innerHTML]="infoComponentHtml"></div>`
})
export class MyContainerComponent implements AfterViewInit {
@Input() infoComponentHtml: string = "";
constructor(private componentFactoryResolver: ComponentFactoryResolver){
}
ngAfterViewInit(): void {
if(this.infoComponentHtml){
??????
append this.infoComponentHtml dynamically
}
else{
??????
append "<default-content></default-content>" dynamically
}
}
}
this.infoComponentHtml
format is like this "<component-name></component-name>"
this.infoComponentHtml
is third party component that comes from another component. So I do not know the component class name of it.
How can I compile and add append the component?