Dynamically Creating Components With Angular
Netanel Basal

Thanks for the article. I am not sure why my container is getting a null, so I was not able to get clear or createComponent(factory); Any light on this one?

I am not able to get past this line.

this.detailComponentRef = this.container.createComponent(factory);

this is what I have

@ViewChild(“detailViewContainer”, { read: ViewContainerRef }) container;

createComponent(row: any) {


const factory: ComponentFactory<any> = this.resolver.resolveComponentFactory(this.tableConfiguration.detailViewComponent)

this.detailComponentRef = this.container.createComponent(factory);

if (this.tableConfiguration.setDetailViewComponentInputs) {




One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.