I added dynamic components (ChildComponent.ts
) inside viewContainerRef. I able to get child count from viewContainerRef like this viewContainerRef.length
if i use index to get Child Component (viewContainerRef.get(0)
) it's return ViewRef
But i need child component how to do this.
Example :
@ViewChild("cards_holder", { read: ViewContainerRef }) cards_holder: ViewContainerRef;
const componentFactory = this.resolver.resolveComponentFactory( SimpleCardComponent);
const componentRef = this.cards_holder.createComponent(componentFactory);
for (let index = 0; index < this.cards_holder.length; index++) {
console.log(this.cards_holder.get(index)) //It's Return ViewRef but i need SimpleCardComponent
}
Thank you. Sabish.M