I would like to create an angle component that consists of several sub-components. Eventually I want to create a large reusable tree component whose nodes have different data types. For each data type, the tree component imports sub-components that specify how the node should be displayed. The user should be able to specify a custom component to override the default component for a particular data type. An import syntax like this would be nice:
<app-tree [customDateComp]="CustomDateComponent"></app-tree>
This could be the simplified tree.component.html:
<ng-container *ngIf="!customDateComp">
<app-default-date></app-default-date>
</ng-container>
<ng-container *ngIf="customDateComp">
{{ customDateComp }}
</ng-container>
Of course this does not work yet, because the components are imported with the syntax. The approach below does not work either, because angular escapes it:
<app-tree [customDateComp]="'<app-custom-date></app-custom-date>'"></app-tree>
The sample code can be found here: https://stackblitz.com/edit/angular-ivy-xghj5f?file=src/app/app.component.html
Does anyone have an idea how to import Angular Components into other Components by specifying the component name as an input parameter? Or is there a better way to override default sub-components of a third-party component? Thanks a lot!