在角教程这里找到: https://angular.io/docs/ts/latest/tutorial/toh-pt3.html什么时候Angular2中的组件元数据需要指令?
的HeroDetailComponent添加为指令app.component.ts:
@Component({
selector: 'my-app',
//...
directives: [HeroDetailComponent]
})
的教程说: “浏览器忽略HTML标签和属性它不能识别Angular也是这样......我们通过将它列入到元数据指令数组中来告诉Angular它(HeroDetailComponent)。“
但是在工作示例这里找到: https://github.com/DeborahK/Angular2-GettingStarted(见APM - 最后更新项目)
app.component.ts加载一个名为ProductDetailComponent组件尚未有这方面没有指令:
@Component({
selector: 'pm-app',
//...
directives: [ROUTER_DIRECTIVES],
})
为什么第二个示例能够加载没有ProductDetailComponent指令的ProductDetailComponent?
>>我希望这会有所帮助。它确实如此。谢谢。 – Sam