I have a component called "Node" which should display a single post, but I have more than a post type and each type has its own view (layout).
So this componen
If you have a limited set of possible templates then *ngIf
or *ngSwitch
is a good approach. It allows you to use []
and ()
bindings between parent and child.
If you have a set of templates that are statically unknown and for example provided by a parameter then *ngIf
doesn't work. Then ViewContainerRef.createComponent()
(replaces DynamicComponentLoader
) is the right approach. For an example see Angular 2 dynamic tabs with user-click chosen components