The pipe ‘ ‘ could not be found angular2 custom pipe

Make sure you are not facing a “cross module” problem

If the component which is using the pipe, doesn’t belong to the module which has declared the pipe component “globally” then the pipe is not found and you get this error message.

In my case I’ve declared the pipe in a separate module and imported this pipe module in any other module having components using the pipe.

I have declared a
that the component in which you are using the pipe is

the Pipe Module

 import { NgModule }      from '@angular/core';
 import { myDateFormat }          from '../directives/myDateFormat';

 @NgModule({
     imports:        [],
     declarations:   [myDateFormat],
     exports:        [myDateFormat],
 })

 export class PipeModule {

   static forRoot() {
      return {
          ngModule: PipeModule,
          providers: [],
      };
   }
 } 

Usage in another module (e.g. app.module)

  // Import APPLICATION MODULES
  ...
  import { PipeModule }    from './tools/PipeModule';

  @NgModule({
     imports: [
    ...
    , PipeModule.forRoot()
    ....
  ],

Leave a Comment