If you look at the HTML of an open datepicker, you will see each day is represented by a td
, like so:
<td class="mat-calendar-body-cell ng-star-inserted" role="gridcell" tabindex="-1" aria-label="February 4, 2018" style="width: 14.2857%; padding-top: 7.14286%; padding-bottom: 7.14286%;"><div class="mat-calendar-body-cell-content">4</div></td>
What we can derive from that HTML is an aria-label
and a class of mat-calendar-body-cell
.
To achieve what you want, you can use the @Output() openedStream
event. This will be triggered whenever the calendar is opened.
As per the docs: @Output('opened') openedStream: EventEmitter<void>
.
Once you receive the event, you can then query the DOM by the mat-calendar-body-cell
class that has a combination of an aria-label
attribute with a certain date, and if there are matches then you can add a class to those matches.
Let me know if you have any issues with that. But you should be able to follow that rubric step by step to achieve what you want.
For more options from the datepicker API, look at the docs here.