我刚刚将我在 RC5 上构建的应用程序升级到最终版本,我对现在应该声明指令和管道的方式感到困惑。我收到此错误:
ERROR in [default] C:\xampp\htdocs\meriem-car\public\src\app\components\administration.component.ts:12:4 Argument of type '{ moduleId: string; selector: string; directives: typeof LoginComponent[]; templateUrl: string; }' is not assignable to parameter of type 'Component'. Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.
最佳答案
自 RC6 起,所有指令和管道都应移至模块的声明
。
@NgModule({
imports: [...],
declarations: [
//you insert your Components, Directives and Pipes here
],
bootstrap: [...],
providers: [...]
})
export class AppModule { }
关于 Angular 2.0 版本 : Pipes and Directives are not properties of @Component anymore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39539085/