I am able to use Date picker to highlight different dates in different colors as shown here: https://material.angular.io/components/datepicker/examples#datepicker-date-class https://stackblitz.com/angular/xxjleavorkm?file=src%2Fapp%2Fdatepicker-date-class-example.html
I however, would like to highlight different dates in different colors. For example, 1 in orange and 20 in green. How do I specify different colors for different dates?
If I use lets say two methods for this, how do I use them in the dateClass binding?
dateClass1: MatCalendarCellClassFunction<Date> = (cellDate, view) => {
// Only highligh dates inside the month view.
if (view === 'month') {
const date = cellDate.getDate();
console.log(date);
// Highlight the 1st of each month.
return date === 1? 'orangeClass' : '';
}
return '';
};
dateClass2: MatCalendarCellClassFunction<Date> = (cellDate, view) => {
// Only highligh dates inside the month view.
if (view === 'month') {
const date = cellDate.getDate();
console.log(date);
// Highlight the 20th day of each month.
return date === 20? 'greenClass' : '';
}
return '';
};
HTML:
<mat-card class="demo-inline-calendar-card">
<mat-calendar [(selected)]="selected" [dateClass]="?" #picker></mat-calendar>
</mat-card>

dateClass is a function that received as argument the "date" and return a string that it's the name of a class. This function is executed 28, 30 or 31 times (one for day). So you can do
Generally you have an array with the dates and the "class", e.g.
And you function like
Or you have an array with only the day of the month
And your function