In my project, I am looking to develop an angle component made up of multiple sub-components. The end goal is to construct a versatile tree component with nodes that cater to different data types. Each data type in the tree component will import specific sub-components that dictate how the node should appear. Users should also have the option to provide a custom component to replace the default one for a particular data type. It would be great if we could use an import syntax like this:
<app-tree [customDateComp]="CustomDateComponent"></app-tree>
Here is a simplified version of the tree.component.html:
<ng-container *ngIf="!customDateComp">
<app-default-date></app-default-date>
</ng-container>
<ng-container *ngIf="customDateComp">
{{ customDateComp }}
</ng-container>
However, it is worth noting that the current method does not function as components are being imported using the incorrect syntax. Another approach where Angular escapes the syntax also fails to work:
<app-tree [customDateComp]="'<app-custom-date></app-custom-date>'"></app-tree>
If you want to check out the sample code, you can find it here: https://stackblitz.com/edit/angular-ivy-xghj5f?file=src/app/app.component.html
Do you have any thoughts on how to efficiently import Angular Components into other Components by specifying the component name as an input parameter? Alternatively, is there a better way to override default sub-components of a third-party component? Thank you!