创建嵌套组件时,angular2模块不符合angular2。我是学习者,如果问题需要更好的演示,请告诉我
答案 0 :(得分:1)
@Component
中的指令必须声明为array
,但您要为其指定HomeComponent[]
应该是这样的:
@Component({
selector: 'my-app',
template: 'my template',
directives: [ HomeComponent ] //<-- like this or remove it completely to declare it in @NgModule
})
还要确保将其包含在@NgModule
@NgModule({
imports: [ BrowserModule],
declarations: [ AppComponent, HomeComponent ], //<-- here
providers: [],
bootstrap: [ AppComponent ]
})