I tried to use DatePipe in my service like this:
import { Injectable } from '@angular/core';
import { DatePipe } from '@angular/common';
import { TranslateService } from '@ngx-translate/core';
@Injectable({
providedIn: 'root',
})
export class BaseService {
public items = [];
constructor(
protected datePipe: DatePipe,
protected translateService: TranslateService
) { }
}
But I get this error: NullInjectorError: No provider for DatePipe!"
. What is the cause?