Angular2+ material customize datepicker date view


Is it possible to customize angular2+ material datepicker’s date view like below?

enter image description here

The main libs and version:

angular: 5.2.9
@angular/material: 5.2.4


Fortunately, I figure out how to resolve it finally.

Coz I’m using angular5, so one possible solution is like this, see below snippet:

      let elements = document.querySelectorAll('.tracker');
      let x =  elements[0].querySelectorAll('.mat-calendar-body-cell');
      x.forEach(y => {
        let c = new Date(y.getAttribute("aria-label"));
        if(c < this.startDate){
          const cellContent = y.querySelector('.mat-calendar-body-cell-content');

For angular6+, you can refer to this sample.

Answered By – Chen Dachao

Answer Checked By – Senaida (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.