angularangular9mat-datepicker

Is there any method to call a function on clicking a date in mat-datepicker other than dateChange in angular 9?


I need to call a function upon clicking a date in mat-datepicker. dateChange only calls a function if the selected date is changed. I need that function to be called if i click on the same date which is previously set. Is there any method to handle this ?


Solution

  • you can always use the "closed" event of the mat-date-picker

      <input #input matInput [matDatepicker]="picker">
      <mat-hint>MM/DD/YYYY</mat-hint>
      <mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle> 
      <mat-datepicker #picker (closed)="emit(input)"></mat-datepicker>