How does Angular6 get the subcomponents and copy or delete them?

< H2 > problem scenario < / H2 > The child component is referenced in the

parent component, as follows:

app.html
<app-parent>
    <app-child></app-child>
</app-parent>

I want to get the parent component or child component in app.component.ts , and copy or delete the component. What should I do?

< H2 > try the solution < / H2 >

I want to get a reference to a child component through viewChild and create a component factory through ng-container . What should I do?

Menu