我是Angular 2的初學者,我正在使用最終的Angular 2發佈版本。我有一個奇怪的問題。 這是我databinding.component.ts代碼:Angular 2錯誤('指令'在'Component'類型中不存在)
import { Component } from '@angular/core';
import {PropertyBindingComponent} from './property-binding.component';
import {EventBindingComponent} from './event-binding.component';
@Component({
selector: 'fa-databinding',
templateUrl: 'databinding.component.html',
styleUrls: ['databinding.component.css'],
directives: [PropertyBindingComponent, EventBindingComponent]
})
,這是我app.module.ts的和平代碼:
import { PropertyBindingComponent } from './databinding/property-binding.component';
import { EventBindingComponent } from './databinding/event-binding.component';
@NgModule({
declarations: [
AppComponent,
OtherComponent,
AnotherComponent,
DatabindingComponent,
PropertyBindingComponent,
EventBindingComponent
]
此代碼不能正常工作:
ERROR in [default] /home/tornado/work/first-app/src/app/databinding/databinding.component.ts:11:2
Argument of type '{ selector: string; template: any; styles: any[]; directives: (typeof PropertyBindingComponent | ...' is not assignable to parameter of type 'Component'.
Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.
我該怎麼辦?!?!
[Angular2版本RC.6「指令」裏面的@Component錯誤](http://stackoverflow.com/questions/39410591/angular2-version-rc-6-directives-inside-component-error) – Fiddles