Наследование классов в Angular Material

export class CustomCalendarHeaderComponent extends MatCalendarHeader<any> implements OnInit {

currentDate: Date = new Date();
showPrev: boolean;
showNext: boolean;
activeMonth: any;
leftActiveDate: string;
rightActiveDate: string;


constructor(_intl: MatDatepickerIntl, calendar: MatCalendar<any>, _dateAdapter: DateAdapter<any>, _dateFormats: MatDateFormats, changeDetectorRef: ChangeDetectorRef) {
    super(_intl, calendar, _dateAdapter, _dateFormats, changeDetectorRef);

}

Пытаюсь кастомизировать заголовок для календаря, унаследовав класс MatCalendarHeader. Я могу его использовать без конструктора. Без конструктора ошибок не возникает. Но тогда не смогу добавить сервис в конструктор этого класса. Есть ли решение использования конструктора с наследованием?

Ошибка

Error: src/app/app.module.ts:54:5 - error NG6001: The class 'CustomCalendarHeaderComponent' is listed in the declarations of the NgModule 'AppModule', but is not a directive, a component, or a pipe. Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.

54     CustomCalendarHeaderComponent
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



src/app/pages/room/components/custom-calendar-header/custom-calendar-header.component.ts:14:14
14 export class CustomCalendarHeaderComponent extends MatCalendarHeader<any> implements OnInit {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'CustomCalendarHeaderComponent' is declared here.


Error: src/app/pages/room/components/custom-calendar-header/custom-calendar-header.component.ts:24:103 - error NG2003: No suitable injection token for parameter '_dateFormats' of class 'CustomCalendarHeaderComponent'.
  Consider using the @Inject decorator to specify an injection token.

24     constructor(_intl: MatDatepickerIntl, calendar: MatCalendar<any>, _dateAdapter: DateAdapter<any>, _dateFormats: MatDateFormats, changeDetectorRef: ChangeDetectorRef, private srv: ActiveDateService) {
                                                                                                     ~~~~~~~~~~~~



src/app/pages/room/components/custom-calendar-header/custom-calendar-header.component.ts:24:117
    24     constructor(_intl: MatDatepickerIntl, calendar: MatCalendar<any>, _dateAdapter: DateAdapter<any>, _dateFormats: MatDateFormats, changeDetectorRef: ChangeDetectorRef, private srv: ActiveDateService) {
                                                                                                                       ~~~~~~~~~~~~~~
    This type does not have a value, so it cannot be used as injection token.
  node_modules/@angular/material/core/datetime/date-formats.d.ts:9:1
      9 export declare type MatDateFormats = {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     10     parse: {
        ~~~~~~~~~~~~
... 
 19     };
    ~~~~~~
 20 };
    ~~
The type is declared here.

Ответы (0 шт):