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

查看:28
本文介绍了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[];模板网址:字符串;}' 不可分配给组件"类型的参数.对象字面量只能指定已知属性,组件"类型中不存在指令".

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

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天全站免登陆