在以下pluker http://plnkr.co/edit/mc7go55tgkqqtrxajnjir?p = preview
在dashboardcomponent类中,在文件
中 Dashboard.Component.ts
定义了带有选择器的@component,但在文件.html中没有选择器等效,您可以向我解释如何可能?您没有被迫定义选择器标签?
DashboardComponent
在Router
中使用。路由器组件不需要selector
属性。
路由器使用的ViewContainerRef.createComponent()
不需要选择器与HTML匹配。另请参见Angular 2 Dynamic Tabs,其中示例使用用户单击选定的组件。
Angular Router可让您直接路由到组件 - 查看App/App -Routing.module.ts: { path: 'dashboard', component: DashboardComponent },
有关更多详细信息,请参见此的"添加路由"链接:https://angular.io/docs/ts/latest/tutorial/toh-pt5.ht5.html