首页 > 解决方案 > 使用角度 9 中的垫选择过滤垫表

问题描述

<div class="row">
        <div class="col-sm-3 col-md-3 col-lg-3 col-xs-3">
            <mat-form-field class="form-field-width">
                <mat-label>Status</mat-label>
                <mat-select (ngModelChange)="onChangeStatus($event)" [(ngModel)]="selectedStatus">
                    <mat-option *ngFor="let option of options" [value]="option.value"> 
                      {{option.viewValue}}
                    </mat-option>
                </mat-select>
            </mat-form-field>
        </div>
        <div class="col-sm-3 col-md-3 col-lg-3 col-xs-3">
            <mat-form-field class="form-field-width">
                <mat-label>Risk Category</mat-label>
                <mat-select (ngModelChange)="onChangeRisk($event)" [(ngModel)]="selectedRisk">
                    <mat-option *ngFor="let risk of risks" [value]="risk.value">{{risk.viewValue}}
                    </mat-option>
                </mat-select>
            </mat-form-field>
        </div>    
    </div>  


 onChangeStatus(event){
    const filterValue = event;
    this.dataSource.filter = filterValue.trim().toLowerCase();
  }
  onChangeRisk(event){
      const filterValue = event
    this.dataSource.filter =  filterValue.trim().toLowerCase();     
  }

大家好,我正在尝试使用 mat-select 框过滤 mat-table。但我无法做到这一点。如果我们在两个选择框中都选择选项,则表格应该过滤选项。请帮忙

标签: javascriptangulartypescript

解决方案


推荐阅读