![](/img/trans.png)
[英]How to check if at least one value of a list of objects in an array is true in Angular?
[英]How to Check If a Value of Objects Matches Any Value in a List of Array in Angular
我有這樣的腳本:
let arrlist = ['Aple','Banana', 'Carrot', 'Onion'];
data = this.tabledata.filter(d=> {
return Object.keys(d).some(key => {
if(searchTerm) {
return String(d[key]).toLowerCase().includes(searchTerm.toLowerCase());
} else {
list.map(r => {return String(d[key]).toLowerCase().includes(r)}); //error
}
});
});
我想從this.tabledata
中過濾與列表匹配或包含arrlist
的數據。 我應該怎么辦? 請幫我
這是this.tabledata
的數組對象:
[ {id: 1, name: "Jake", things: "Aple"}
{id: 2, name: "Anwar", things: "Carrot"}
{id: 3, name: "Lane", things: "Aple"}
{id: 4, name: "Curt", things: "Banana"}
{id: 5, name: "Pety", things: "Carrot"}
{id: 6, name: "Hary", things: "Aple"}
{id: 7, name: "Clara", things: "Aple"} ]
我有這樣的腳本:
let arrlist = ['Aple','Banana', 'Carrot', 'Onion'];
data = this.tabledata.filter(d=> {
return Object.keys(d).some(key => {
if(searchTerm) {
return String(d[key]).toLowerCase().includes(searchTerm.toLowerCase());
} else {
list.map(r => {return String(d[key]).toLowerCase().includes(r)}); //error
}
});
});
我想從this.tabledata
中過濾與列表匹配或包含arrlist
的數據。 我應該怎么辦? 請幫我
這是this.tabledata
的數組對象:
[ {id: 1, name: "Jake", things: "Aple"}
{id: 2, name: "Anwar", things: "Carrot"}
{id: 3, name: "Lane", things: "Aple"}
{id: 4, name: "Curt", things: "Banana"}
{id: 5, name: "Pety", things: "Carrot"}
{id: 6, name: "Hary", things: "Aple"}
{id: 7, name: "Clara", things: "Aple"} ]
我有這樣的腳本:
let arrlist = ['Aple','Banana', 'Carrot', 'Onion'];
data = this.tabledata.filter(d=> {
return Object.keys(d).some(key => {
if(searchTerm) {
return String(d[key]).toLowerCase().includes(searchTerm.toLowerCase());
} else {
list.map(r => {return String(d[key]).toLowerCase().includes(r)}); //error
}
});
});
我想從this.tabledata
中過濾與列表匹配或包含arrlist
的數據。 我應該怎么辦? 請幫我
這是this.tabledata
的數組對象:
[ {id: 1, name: "Jake", things: "Aple"}
{id: 2, name: "Anwar", things: "Carrot"}
{id: 3, name: "Lane", things: "Aple"}
{id: 4, name: "Curt", things: "Banana"}
{id: 5, name: "Pety", things: "Carrot"}
{id: 6, name: "Hary", things: "Aple"}
{id: 7, name: "Clara", things: "Aple"} ]
我有這樣的腳本:
let arrlist = ['Aple','Banana', 'Carrot', 'Onion'];
data = this.tabledata.filter(d=> {
return Object.keys(d).some(key => {
if(searchTerm) {
return String(d[key]).toLowerCase().includes(searchTerm.toLowerCase());
} else {
list.map(r => {return String(d[key]).toLowerCase().includes(r)}); //error
}
});
});
我想從this.tabledata
中過濾與列表匹配或包含arrlist
的數據。 我應該怎么辦? 請幫我
這是this.tabledata
的數組對象:
[ {id: 1, name: "Jake", things: "Aple"}
{id: 2, name: "Anwar", things: "Carrot"}
{id: 3, name: "Lane", things: "Aple"}
{id: 4, name: "Curt", things: "Banana"}
{id: 5, name: "Pety", things: "Carrot"}
{id: 6, name: "Hary", things: "Aple"}
{id: 7, name: "Clara", things: "Aple"} ]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.