【发布时间】:2019-05-22 01:20:11
【问题描述】:
我有一个结构如下的对象。
Object{
Array [{
property1: "",
property2: "",
innerArray: [{
arrayProperty1
arrayProperty2
}]
}]
}
innerArray.Property2 过滤的最佳方式是什么?我有一个需要应用的过滤器列表。下面的代码是我目前尝试应用过滤器的方式,但列表根本没有改变。
if(filterList)
{
// if this length is 0, don't include inventory in the filter
let filterOnInventoryId = filterList.filter((item: any) => {
return (item && item.Type === 'InventoryId');
});
let shouldFilterInventoryId = filterOnInventoryId && filterOnInventoryId.length > 0;
let shouldFilterAppointmentType = filterOnAppointmentType && filterOnAppointmentType.length > 0;
// find any inventoryIds that are part of the filter, else return an empty list
let filteredListInventoryId = shouldFilterInventoryId ? filterOnInventoryId.filter((item: any) =>
{
var x = this.selectedDateAndAppointmentList.filter((dateModelAndAppointment: any) =>
{
return dateModelAndAppointment.appointmentList.filter((appointment: any) =>{
item.InventoryTypeId == appointment.Inventory.InventoryTypeId;
})
})
return x;
}) : [];
}
【问题讨论】:
标签: javascript arrays angularjs typescript