I have created some components through the code like:
resolveCom(com: any, viewContain: ViewContainerRef): ComponentRef<any> {
let comFac = this.componentFactoryResolver.resolveComponentFactory(com)
let newCom: ComponentRef<any> = viewContain.createComponent(comFac)
newCom.changeDetectorRef.detectChanges()
return newCom
}
And I dynamic create some compoennts and save them into the array:
let newCom: ComponentRef<any> = this.resolveCom(item, viewContain)
saveCom[key].push(newCom)
The view can show the components that were created.Now i want to hide or show these components but i don't want to destroy them and recreate them. I saved them just now,can i dynamic insert the component that i save to the view ?