I am using in my Angular Project. I wanted to catch the event and get the month and year value when user click on navigation button at top for changing month.
After a lot of search I managed to get following piece of code to grab the click event. I am not able to get the month and year value. How to get it?
HTML
<mat-calendar [minDate]="minDate" [maxDate]="maxDate" [dateClass]="dateClass()" [dateFilter]="futureEventFilter"
#calendar (monthSelected)="monthSelected($event)" (selectedChange)="getDateChangedValue($event)" [(selected)]="selectedDate">
</mat-calendar>
TS Code
ngAfterViewInit() {
let buttons = document.querySelectorAll('mat-calendar .mat-calendar-previous-button,' +
'mat-calendar .mat-calendar-next-button');
if (buttons) {
Array.from(buttons).forEach(button => {
this.renderer.listen(button, "click", () => {
//this.monthSelected($event);
console.log(button)
});
})
}
}
public monthSelected(date) {
alert(date);
}
How to call monthSelected and retrieve month and year value? Please help here.