Add to providers array in the component
@Component({
selector: 'app-root',
templateUrl: '...',
providers:[DatePipe]
})
or inject it to module
@NgModule({
providers:[DatePipe]
})
or write a separate class extending the DatePipe and use it as a service
@Injectable()
export class CustomDatePipe extends DatePipe {
transform(value, format) {
return super.transform(value, format);
}
}
and inject this to providers array
@Component({
selector: 'app-root',
templateUrl: '...',
providers:[CustomDatePipe]
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…