Angular 2.0 版本 : Pipes and Directives are not properties of @Component anymore

标签 angular angular-directive angular-pipe

我刚刚将我在 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/

相关文章:

javascript - Angular 2 : uiRouter get current state params in root component

angular - 在不编码的情况下将字符串作为路由参数传递给 Angular

Angular:在组件中声明服务和引导过程有什么区别

javascript - AngularJS:从指令内访问数据绑定(bind)的值

Angular 5 - 如何在 DatePipe 中使周期字段类型小写

angular - 如何检查 ng-content 是否存在

angularjs - ng-click 不调用函数

Angular : How do i override directive's style in my view?

angular - 如何使用管道突出显示 Angular6 中搜索到的文本?

angular - 如何在 Angular 5 响应式(Reactive)表单输入中使用管道