Вы можете немного изменить компонент из примера:
import { Component, AfterViewChecked, ViewChild, ChangeDetectorRef } from '@angular/core';
import { CalendarEvent } from 'angular-calendar';
@Component({
selector: 'mwl-demo-component',
templateUrl: 'template.html'
})
export class DemoComponent implements AfterViewChecked {
view: string = 'month';
viewDate: Date = new Date();
events: CalendarEvent[] = [];
clickedDate: Date;
@ViewChild('monthView') monthView;
constructor(private cdr: ChangeDetectorRef) {}
ngAfterViewChecked() {
const emittedValue = {
day: {
badgeTotal: 0,
date: new Date(),
events: [],
inMonth: true,
isFuture: false,
isPast: false,
isToday: true,
isWeekend: false,
},
};
this.monthView.dayClicked.emit(emittedValue);
this.cdr.detectChanges();
}
}
И не забудьте добавить переменную monthView
в mwl-calendar-month-view
:
<mwl-calendar-month-view
#monthView
*ngSwitchCase="'month'"
[viewDate]="viewDate"
[events]="events"
(dayClicked)="clickedDate = $event.day.date">
</mwl-calendar-month-view>