I want dynamically remove components from my parent component.
<div>
<my-component #component
(remove)="onRemove(0)">
</my-component>
<my-component #component
(remove)="onRemove(1)">
</my-component>
<my-component #component
(remove)="onRemove(2)">
</my-component>
</div>
child component emits to the parent, it works, in onRemove function:
constructor(private generalViewContainerRef: ViewContainerRef) {
}
private onRemoveWidget(index:number) {
this.generalViewContainerRef.remove(component);
}
but it's not working.
how can I do it?