【发布时间】:2022-11-28 14:38:37
【问题描述】:
我有一个这样的数组
{
"id": 1,
"name": "this is book",
}
{
"id": 2,
"name": "this is a test book",
}
{
"id": 3,
"name": "this is a desk",
}
过滤数组时,我想返回示例中包含书籍的数组
我试过了
let test = this.pro.filter((s: { name: any; })=>s.name===book);
不在搜索中工作 并尝试
let test = this.pro.filter((s: { name: any; })=>s.name===this is book);
工作但只返回 id 1 它应该返回 id 1 & 2
任何解决方案 谢谢;
【问题讨论】:
-
这回答了你的问题了吗? How to filter object array based on attributes?
-
换成
'book'
标签: angular typescript