Thanks for sharing your approach with us.
I’m curious why you didn’t use
NgComponentOutlet or dynamic rendering rather than
Thanks for your comment.
We have chosen
NgSwitch because it seemed simple and straightforward. However, it is clearly repetitive and not very elegant.
We will thus consider using the approaches you suggested (I have just created a task for this and assigned it to me :-)). We will have to make sure though that value components can still receive specific inputs (inputs that are not defined in the base class, but just in one specific component).
I have used the component portal once (https://github.com/angular/components/pull/9639) but the component that you could pass in did not require any further configuration.
I see. Andrew Grekov aka thekiba aka Reactive Fox made the library NGXD which does what you’re asking for:
As its readme says, you can do the same thing with
ComponentFactoryResolver and a
ViewContainerRef, but you have to do bindings and some wiring manually. This is what I meant by dynamic rendering (that or
NgComponentOutlet allows content projection and injector inheritance, but doesn’t allow binding.
Thanks for the reference to https://github.com/IndigoSoft/ngxd!
Do you happen to know if this will be integrated into Angular some day?
I’ll get the NGXD author in here to join the discussion.