【发布时间】:2016-09-10 04:45:31
【问题描述】:
在此处找到的角度教程中: https://angular.io/docs/ts/latest/tutorial/toh-pt3.html
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?
【问题讨论】:
标签: angular angular2-directives