Angular 2.0 Release: Pipes and Directives are not properties of @Component anymore

*爱你&永不变心* 提交于 2019-12-03 11:19:00

问题


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:

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


回答1:


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 { }


来源:https://stackoverflow.com/questions/39539085/angular-2-0-release-pipes-and-directives-are-not-properties-of-component-anymo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!