[英]Angular2 component with selector not in the html
in the following pluker http://plnkr.co/edit/MC7gO55TGkQTrxaJnJir?p=preview 在以下插件中http://plnkr.co/edit/MC7gO55TGkQTrxaJnJir?p=preview
in the DashboardComponent class, in the file 在DashboardComponent类的文件中
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? 定义了一个带有选择器的@component,但是在.html文件中没有等效的选择器,您可以向我解释怎么可能? you are not forced to define the selector tag ?
您不是必须要定义选择器标签吗?
The DashboardComponent
is used in the Router
. DashboardComponent
在Router
。 A router component does not need a selector
property. 路由器组件不需要
selector
属性。
The router uses ViewContainerRef.createComponent()
which doesn't need the selector to match HTML. 路由器使用
ViewContainerRef.createComponent()
,不需要选择器来匹配HTML。 See also Angular 2 dynamic tabs with user-click chosen components for an example. 有关示例,另请参阅带有用户单击所选组件的Angular 2动态选项卡 。
The Angular router lets you route to a component directly - have a look at app/app-routing.module.ts: { path: 'dashboard', component: DashboardComponent },
Angular路由器可让您直接路由至组件-查看app / app-routing.module.ts:
{ path: 'dashboard', component: DashboardComponent },
See the "Add Routing" link of this for more detail: https://angular.io/docs/ts/latest/tutorial/toh-pt5.html 有关更多详细信息,请参见此链接的“添加路由”: https : //angular.io/docs/ts/latest/tutorial/toh-pt5.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.