我是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