【发布时间】:2021-09-03 07:03:03
【问题描述】:
我正在使用来自 Angular Material 网站 https://material.angular.io/components/table/examples 的示例 Table with filtering
我想让用户使用通配符进行搜索。在这种情况下,%
我写了以下内容:
const filterValue = (event.target as HTMLInputElement).value;
let filterArray = filterValue.trim().toLowerCase().split("%");
for (let fil of filterArray) {
//I know this line below won't work, as it will just replace the filter with each iteration, but showing for sake of example
this.tableData.filter = fil;
}
因此,如果用户在输入字段中键入one%two,我希望过滤器找到在行中某处同时存在单词“one”和“two”的表行。
我尝试了几种代码变体,但似乎没有什么能完全正确。关于如何完成这项工作的任何想法?
【问题讨论】:
标签: angular typescript angular-material