由垫选择过滤材料的角度数据表

问题描述 投票:-1回答:2

我有一个排序,过滤器和分页垫桌子。现在,我正在寻找一种方式用毡选择过滤matTableDataSource。这是我的代码Stackblitz有人可以帮助我?

angular angular-material filtering mat-table
2个回答
0
投票

只需使用(selectionChange) @Output属性,并通过它选择的mat-option的价值在你mat-select。这是东西,你可以通过$event.value得到:

<div class="col-sm-4 col-md-4">
  <mat-form-field>
    <mat-select 
      placeholder="Version" 
      (selectionChange)="applyFilter($event.value)">
      <mat-option 
        *ngFor="let version of versions" 
        [value]="version">
        {{version}}
      </mat-option>
    </mat-select>
  </mat-form-field>
</div>

以下是为您的参考一Working Sample StackBlitz


0
投票

你可以用它发射对MAT-选项也喜欢(click)事件相同的功能:

而在你的共享例子中,你已经使用[value]="version.value"但它应该是[value]="version",而不是因为它不具有这样的性质称为value

<mat-form-field>
     <mat-select placeholder="Version">
      <mat-option *ngFor="let version of versions" [value]="version" (click)="applyFilter(version)">
              {{version}}
       </mat-option>
     </mat-select>
</mat-form-field>

Stackblitz

© www.soinside.com 2019 - 2024. All rights reserved.