2016-09-16 58 views
15

我刚刚将我在RC5上构建的应用程序升级到最终版本,我对现在应该声明Directives和Pipes的方式感到困惑。我得到这个错误:Angular 2.0发布:管道和指令不再是@Component的属性

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'.

回答

33

由于RC6,所有指令和管道应该被移动到模块的declarations

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

export class AppModule { } 
+2

它做到了,谢谢:) –

+0

@ESturzenegger你是否从组件中删除了'directives'? –

+1

sry删除我的问题:“即使将它添加到声明后,它也会显示相同的错误”@StefanSvrkota是的,我做过。有趣的是:管道工程,但错误显示在我的cli。 –

相关问题