The overall page is a component template. There is a child component that has been declared and used in the parent component template. Now I want to dynamically create the child component inside the child component. I have tried this:
getViewRef
is used to dynamically create sub-components FileUploadEle
Although it can be created correctly, the created element does not belong to PhoneComponent
as shown in the figure:
Becomes a brother element.
What to do to correctly create parent-child instead of sibling.
It’s ready, use the template command
I don’t understand your specific needs, but I think it’s better to use template declaration instead of creating components in js.
Pay attention to <ng-content>
below