Is it possible to limit the user to selecting only up to 5 options in a <mat-select multiple>
? How can I achieve this?
I tried using the selectionChange
event, but I couldn't find a way to visually prevent the user from selecting more than 5 options.
<mat-select [(ngModel)]="orderSearchModel.analystId" name="analyst" (selectionChange)="onChangeAnalyst($event)" multiple>
<mat-option (click)="clearAnalyst()">clear</mat-option>
<mat-option *ngFor="let user of users" [value]="user.value">{{user.name}}</mat-option>
</mat-select>
I want to restrict the user from selecting more than 5 options in my multi-select
.