I'm trying to add a component dynamically using cdk's ComponentPortal
@Component {
selector: 'my-app',
template: '<div #container></div>',
styleUrls: [ './app.component.css' ]
}
export class AppComponent {
@ViewChild('container', {read: ViewContainerRef, static: false}) container;
ngAfterViewInit(): void {
const dialogContent = new ComponentPortal(BarfooComponent, this.container);
}
}
As you can see from the demo this code doesn't throw any errors, but also renders nothing :(
So, I'm not sure if anything like this is even possible with ComponentPortal
and if so I probably miss one or more steps here. Any suggestions how I can do this?