Angular 2.0版本:管道和指令不再是@Component的属性 [英] Angular 2.0 Release: Pipes and Directives are not properties of @Component anymore

查看:99
本文介绍了Angular 2.0版本:管道和指令不再是@Component的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我基于RC5构建的应用程序升级到了最终版本,我对现在应该声明指令和管道的方式感到困惑.我收到此错误:

I just upgraded my app which I built on RC5 to the final release, and I'm confused of the way I should be declaring Directives and Pipes now. I'm getting this error:

[默认] C:\ xampp \ htdocs \ meriem-car \ public \ src \ app \ components \ administration.component.ts:12:4中的错误 类型'{moduleId:string;选择器:字符串;指令:typeof LoginComponent []; templateUrl:字符串; }"不可分配给组件"类型的参数. 对象文字只能指定已知的属性,指令"在组件"类型中不存在.

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开始,所有指令和管道都应移至模块的declarations.

Since RC6, all Directives and Pipes should be moved to module's declarations.

@NgModule({
    imports: [...],
    declarations: [
        //you insert your Components, Directives and Pipes here
    ],
    bootstrap: [...],
    providers: [...]
})

export class AppModule { }

这篇关于Angular 2.0版本:管道和指令不再是@Component的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆