2

I am using Angular material Datepicker for date selection in My project. can anyone have a Solution to show years from a particular range.

Ex: I want to show years from 1950 in my Material Date Picker. years before 1950 should be removed from Datepicker. is there any solution for this from Angular Material.

Santosh Raju
  • 156
  • 2
  • 13

1 Answers1

1

I have tested below code.Declare minDate and use it in tag

typescript code

export class DatepickerMinMaxExample {
  minDate: Date;


  constructor() {

    this.minDate = new Date(1950, 0, 1);

  }
}

html Code (Use [min]="minDate" )

<mat-form-field class="example-full-width">
  <mat-label>Choose a date</mat-label>
  <input matInput [min]="minDate" [matDatepicker]="picker">
  <mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
  <mat-datepicker #picker></mat-datepicker>
</mat-form-field>
Vishal Pawar
  • 356
  • 4
  • 12