我是 Angular 2 的菜鸟。我正在做 YouTube 教程,但每个教程都有directives:
我被困的部分。
应用程序组件.ts
import { Component } from '@angular/core';
import { HeaderComponent } from './components/header/header.component'
@Component({
selector: 'my-app',
template: '<h1>Hello</h1><header></header>',
directives: [HeaderComponent]
})
export class AppComponent { }
错误输出为:
Argument of type '{ selector: string; template: string; directives: typeof HeaderComponent[]; }' is not assignable to parameter of type 'ComponentMetadataType'.at line 6 col 3
header.component.ts
import { Component } from '@angular/core';
@Component ({
selector: 'header',
template: '<h2>hit!</h2>'
})
export class HeaderComponent { }
Here's an screenshot of the error
directives
财产被移除于RC.6
你应该把它移到declarations
你的财产NgModule装饰者
@NgModule({
imports: [ BrowserModule ],
declarations: [ AppComponent, HeaderComponent ], <== here
bootstrap: [ AppComponent ]
})
export class AppModule { }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)