angular2 error with pipe filter in component

二次信任 提交于 2019-12-04 16:54:37
Pardeep Jain

Most probably, you are using ngModule approach for your app if so than you are importing your pipe in incorrect way, you have to import your pipe in the module instead of your component i.e. orders component in your use case.

Try importing your pipe in higher module like this:

@NgModule({
  declarations: [FilterPipe,.... ],
  imports: [.... ],
  providers: [....],
  bootstrap: [AppComponent]
})
export class AppModule { }

P.S:- Moreover, you can also create your pipe as module to import this in more than one modules.

Hint: There is no need to add @Injectable() when there is already @Pipe(), @Component(), or @Directive()

Ensure you have FilterPipe added to declarations: [FilterPipe] of your current module

or

added the module that has

declarations: [FilterPipe],
exports: [FilterPipe]

to imports: [...] of your current module.

if you are using angular 4, then you do not need to specify pipes in you @Component.

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