角度見つかりませんでした私は、角度4で私のカスタムパイプを実装する必要がありますが、私はこのカスタムパイプを使用しようとするコンポーネントで、私は次のエラーがあります。カスタムパイプ4
<div>{{ selected.lastModifiedDate | formatdate}}</div>
Template parse errors: The pipe 'formatdate' could not be found
私を現時点では、カスタムパイプが空である:
formatdate.pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'formatdate'
})
export class FormatdatePipe implements PipeTransform {
transform(value: any, args?: any): any {
return null;
}
}
私持っ共有パイプモジュール
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: [],
};
}
}
そして
import { PipeModule } from './shared/pipes/pipe.module';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(routes),
PipeModule.forRoot(),
....
問題がある私の主なアプリモジュール
app.moduleで?多分モジュールで何か
パイプモジュールを作成した理由はありますか?これは不要です。 app.module宣言にパイプをインクルードするだけです。 https://stackoverflow.com/documentation/angular2/1165/pipes/3756/custom-pipes#t=201706301331556332039 –
それは私はすでに私はインポートする場合、それは動作します – Alessandro
このエラーを持っているので、私はモジュールを作成した、変更されません。あなたはそれをインポートする必要が – Alessandro