Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material <mat-select> - execute function on blur

I have a <mat-select> element and I want to execute a function on blur of the element.

currently the function executes on selection change:

<mat-form-field fxFlex>
  <mat-label>SSR Status</mat-label>
  <mat-select [formControl]="ssrStatuses" multiple (selectionChange)="filtersUpdated()" [(value)]="selectedSsrStatuses">
    <mat-option *ngFor="let ssrStatus of ssrStatusList" [value]="ssrStatus.id">{{ssrStatus.label}}</mat-option>
  </mat-select>
</mat-form-field>

I can't see any mention of blur or focus in the angular material mat-select docs. These docs on angular 4 mention (blur)="myMethod()" but that doesn't work on my <mat-select>. How do I execute a function on blur of <mat-select>?

like image 956
BeniaminoBaggins Avatar asked Sep 09 '26 00:09

BeniaminoBaggins


1 Answers

If it is still actual, try to use closed event:

<mat-select (closed)="someMethod()">
  <mat-option></mat-option>
</mat-select>
like image 199
alexdf Avatar answered Sep 10 '26 15:09

alexdf



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!