Dynamically Creating Components With Angular
Netanel Basal
1.1K26

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) {

this.container.clear();

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

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

if (this.tableConfiguration.setDetailViewComponentInputs) {

this.tableConfiguration.setDetailViewComponentInputs(row);

}

}

One clap, two clap, three clap, forty?

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