【发布时间】:2021-07-19 17:57:54
【问题描述】:
我有一个 Angular Material 表。我创建了一个与数据源的“过滤器”功能一起使用的搜索栏。我创建了一个 mat select,它与数据源的“filterpredicate”功能一起使用。当我只使用其中一个时,它们都可以工作。但是当我使用一个时,第二个就不能正常工作了。我不知道如何同时使用两个过滤器。
search(event: Event) {
const filterValue = (event.target as HTMLInputElement).value;
this.dataSource.data = this.dataSource.filteredData;
}
setTypeOfError(error): void {
this.dataSource.filterPredicate = (myObject: MyObject, filter: string) => {
// return true if the myObject should be displayed
return this.selection.length > 0
? this.selection.some(error => error === myObject.error)
: true;
};
this.dataSource.filter = 'only used to trigger filter';
}
【问题讨论】:
标签: angular angular-material filtering