Search code examples
angularangular-module

Angular 2 RC.5 Shared Module can't find pipes


I'm updating my app to use a module structure and I ran into a weird issue when trying to add my pipe component into a shared module. From what I've read I have everything set up right, so I must be missing something little.

Error: Unhandled Promise rejection: Template parse errors: The pipe 'cmgTitleize' could not be found

I have a BrowseModule, this module declares a ProjectCardComponent which has a template that uses the cmgTitleize pipe. To provide access to the TitleizePipe I import my SharedModule.

@NgModule({
  declarations: [
    ...,
    ProjectCardComponent
  ],
  imports: [
    ...,
    SharedModule
  ],
  providers: [
    ...
  ]
})

export class BrowseModule { }

The SharedModule, imports the PipesModule:

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

export class SharedModule { }

PipesModule declares and exports the TitelizePipe:

@NgModule({
  declarations: [
    ...
    TitleizePipe
  ],
  exports: [
    ...
    TitleizePipe
  ]
})

export class PipesModule { }

Lastly for a sanity check heres the TitleizePipe:

@Pipe({
  name: 'cmgTitleize'
})

export class TitleizePipe implements PipeTransform {
  ...
}

Solution

  • Looks like I just needed to also export the PipesModule in the SharedModule