Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular material date picker close event

I am using Angular material date picker as below. when date picker is closed, I need to apply the CSS. FYI, I don't have any button to close the popup

Code:

 <input
          matInput
          #resultPickerModel="ngModel"
          [matDatepicker]="pickerEndDate"
          [(ngModel)]="endDate"
          (click)="pickerEndDate.open()"
          name="endDate"
          [min]="minStartDate"
          [max]="maxEndDateDate"
        />
        <mat-datepicker #pickerEndDate></mat-datepicker>

My expectation is that I need to apply the CSS when calendar is closed. Kindly help me to do that

like image 796
Muthukumar Marichamy Avatar asked Mar 18 '26 19:03

Muthukumar Marichamy


1 Answers

simply you can use close event then based on your logic you can apply your css using ngStyle

<mat-datepicker #picker (closed)="onClose()"></mat-datepicker>

<div [ngStyle]="{'background-color':condition ? 'green' : 'red' }" ></div>


onClose(){
    //your condition logic
  }
like image 70
wessam yaacob Avatar answered Mar 20 '26 12:03

wessam yaacob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!