2016-09-16 55 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。 –

相關問題