在我的應用程序需要在全球範圍的自定義管道,我嘗試實現它下面angular pipe 但我看到總是這個錯誤角定製管不會被發現
模板解析錯誤:管「formatdate」不能發現
formatdate.pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'formatdate'
})
export class FormatdatePipe implements PipeTransform {
transform(dateJson: any, args?: any): any {
.
//code...
.
return dateJson;
}
}
}
app.module
import { FormatdatePipe } from './shared/pipes/formatdate.pipe';
@NgModule({
declarations: [
AppComponent, FormatdatePipe
],
如果我導入它在我所有的模塊,而不是在主app.module這條管道的作品,我需要一個routin管模塊或東西
你在哪裏使用它? – Sajeetharan
在許多子組件中 – Alessandro
您需要導出管道然後在其他模塊中使用該模塊 – Sajeetharan