Is it possible to override the built-in Angular 2 pipes so they can be used globally?

后端 未结 3 718
太阳男子
太阳男子 2021-01-11 10:49

I would like to override the \"date\" pipe and enjoy the benefit of global access everywhere just like the built-in pipe--aka, avoid having to import and use pipes[] array i

3条回答
  •  旧巷少年郎
    2021-01-11 11:21

    Eric Martinez' answer works fine! Just keep in mind that PLATFORM_PIPES is deprecated in Angular4. Platform pipes in Angular4 are configured via app.modules:

    /**
     * `AppModule`
     */
     @NgModule({
        ...
        providers: [
           ...
           CustomDatePipe
        ]
    })
    

提交回复
热议问题