I have to implements my custom Pipe in angular 4, but in the component when I try to use this custom pipe I have the following error:
<div>{{ selected.lastModifiedDate | formatdate}}</div>
Template parse errors: The pipe 'formatdate' could not be found
my custom pipe at the moment is empty:
formatdate.pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'formatdate'
})
export class FormatdatePipe implements PipeTransform {
transform(value: any, args?: any): any {
return null;
}
}
I have a shared pipe module
pipe.module
import { NgModule } from '@angular/core';
import { FormatdatePipe } from '../pipes/formatdate.pipe';
@NgModule({
imports: [],
declarations: [FormatdatePipe],
exports: [FormatdatePipe],
})
export class PipeModule {
static forRoot() {
return {
ngModule: PipeModule,
providers: [],
};
}
}
And in my principal app module
app.module
import { PipeModule } from './shared/pipes/pipe.module';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(routes),
PipeModule.forRoot(),
....
Where is the problem? maybe something in the module