T-student T-student - 17 days ago 6
TypeScript Question

Angular2 component with selector not in the html

in the following pluker http://plnkr.co/edit/MC7gO55TGkQTrxaJnJir?p=preview

in the DashboardComponent class, in the file

Dashboard.Component.ts


is defined a @component with a selector but in the file .html
there is no selector equivalent, you can explain me how is possible?
you are not forced to define the selector tag ?

Answer

The router uses ViewContainerRef.createComponent() which doesn't need the selector to match HTML. See also Angular 2 dynamic tabs with user-click chosen components for an example.