Angular 2.0版本:管道和指令不再是@Component的属性 [英] Angular 2.0 Release: Pipes and Directives are not properties of @Component anymore
问题描述
我刚刚将我基于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屋!