Angular Mat Select Multiple selectionchange finding which option was changed

前端 未结 2 1998
醉酒成梦
醉酒成梦 2020-12-09 03:38

I have a with the multiple option set (a multi-select). When the selectionChange event fires I need to know which o

相关标签:
2条回答
  • 2020-12-09 03:51

    This worked for me. blahs is an array of strings in this case. Use 2-way binding:

    <mat-select placeholder="choose..." [(value)]="selected" 
          (selectionChange)="somethingChanged(selected)">
      <mat-option *ngFor="let b of blahs; index as i;" value={{b[i]}}">{{b[i]}}
      </mat-option>
    </mat-select>
    
    0 讨论(0)
  • 2020-12-09 03:52

    I needed to use onSelectionChange on the <mat-option>, which is different than the selectionChange that you can use on the <mat-select>

    It would be nice if that was in the documentation for mat-select.

    Here it is working https://stackblitz.com/edit/angular-1e9gsd-34hrwg?file=app/select-overview-example.html

    0 讨论(0)
提交回复
热议问题