public search (searchApartmentList: string[], searchRentList: string[], searchResourceList: string[]): void {
this.searchApartmentList = searchApartmentList;
this.searchRentList = searchRentList;
this.searchResourceList = searchResourceList;
console.log(this.searchApartmentList, this.searchRentList, this.searchResourceList);
const filterFunc = (item: any) => (this.searchApartmentList.length ? this.searchApartmentList.some((apartment_code: string) => item.apartment_code.indexOf(apartment_code) !== -1) : true) && (this.searchRentList.length ? this.searchRentList.some((rent_status: string) => item.rent_status.indexOf(rent_status) !== -1) : true) && (this.searchResourceList.length ? this.searchResourceList.some((resource_code: string) => item.resource_code.indexOf(resource_code) !== -1) : true);
const data = this.dataSet.filter((item: any) => filterFunc(item));
console.log(data);
if (this.sortName) {
this.displayData = data.sort((a: any, b: any) => (this.sortValue === "ascend") ? (a[this.sortName] > b[this.sortName] ? 1 : -1) : (b[this.sortName] > a[this.sortName] ? 1 : -1));
console.log(this.displayData);
} else {
this.displayData = data;
}
}
When is called, the searchReasourceList of the empty array becomes undefined
.
becomes two items & & that"s fine. Why