我的对象中有两个数组,导致我可以实际过滤一个数组,但不能过滤第二个数组。
这是我的过滤谓词,适用于区域数组,但不适用于数组propertyType。有人知道我也要过滤第二个数组吗?
this.dataSource.filterPredicate = (data, filter: string) => {
const accumulator = (currentTerm, key) => {
return key === 'district' ? currentTerm + data.district.name : currentTerm + data[key];
};
const dataStr = Object.keys(data).reduce(accumulator, '').toLowerCase();
// Transform the filter by converting it to lowercase and removing whitespace.
const transformedFilter = filter.trim().toLowerCase();
return dataStr.indexOf(transformedFilter) !== -1;
};
接口
export interface Property {
city: string;
description: string;
district: District; <-- here
efficiencyRating: EfficiencyRating; <-- here
houseno: string;
id: number;
name: string;
propertyType: PropertyType; <-- here
}