Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 使用角材料表的过滤器_Angular_Angular Material - Fatal编程技术网

Angular 使用角材料表的过滤器

Angular 使用角材料表的过滤器,angular,angular-material,Angular,Angular Material,我想知道如何添加一个过滤器到我的表中,使用角度材料,我想过滤器过滤所有列和行,任何帮助将不胜感激,thnx和good day:D <table class="table table-hover"> <thead> <tr> <th scope="col">Rut</th> <th scope="col">Nombre Paciente</th> <th

我想知道如何添加一个过滤器到我的表中,使用角度材料,我想过滤器过滤所有列和行,任何帮助将不胜感激,thnx和good day:D

  <table class="table table-hover">

  <thead>
    <tr>
      <th scope="col">Rut</th>
      <th scope="col">Nombre Paciente</th>
      <th scope="col">Apellido Paciente</th>
      <th scope="col">Teléfono</th>
        <th scope="col">Dirección</th>
      <th scope="col">Acciones</th>

    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let pacientes of pacientes">
     <td>{{pacientes.rutPac}}</td> 
     <td>{{pacientes.nombrePac}}</td> 
       <td>{{pacientes.apellidoPac}}</td> 
     <td>{{pacientes.telefonoPac}}</td> 
     <td>{{pacientes.direccionPac}}</td> 
     <td>
   <button class="btn btn-secondary" type="button" href="#updatePaciente" data-toggle="modal"  (click)="examenClicked(pacientes)">Editar</button>  
   <button class="btn btn-danger" (click)="delete(pacientes)">Borrar</button>
     </td>    
    </tr>
  </tbody>
</table>

如果您使用的是材质表,则需要提供我们自己的输入字段和自定义函数来过滤数据,以使用MatTableDataSource的filter属性,如前所述

范例


这不是物料表。
<div fxLayout fxLayoutAlign="center center">
  <mat-form-field fxFlex="40%">
    <input matInput type="text" (keyup)="filterTable($event.target.value)" placeholder="Filter">
  </mat-form-field>
</div>
public filterTable = (value: string) => {
    this.dataSource.filter = value.trim().toLocaleLowerCase();
  }