过滤角度5中的“角度材料"表中的特定列 [英] Filtering specific column in Angular Material table in angular 5

查看:40
本文介绍了过滤角度5中的“角度材料"表中的特定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Angular Material官方网站中提到filterPredicate:(((data:T,filter:string)=> boolean)将根据特定字段过滤数据.但是不要开始.

In Angular material official website it is mentioned that filterPredicate: ((data: T, filter: string) => boolean) will filter data based on specific field. But don't getting how to start.

我看到了示例,但没有得到:- https ://stackblitz.com/edit/angular-material2-table?file = app%2Fapp.component.html

I have seen example but not getting:-https://stackblitz.com/edit/angular-material2-table?file=app%2Fapp.component.html

默认情况下,它基于整个对象进行过滤,但是我只想基于json的单个属性进行搜索.

By default it filter based on whole object but i want to search only based on single property of json.

推荐答案

我设法做到了:

this.dataSource.filterPredicate = (data, filter) =>
      (data.name.indexOf(filter) !== -1 ||
        data.id.indexOf(filter) !== -1 );
  }

这篇关于过滤角度5中的“角度材料"表中的特定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆