我试图创建一个输入字段,用于过滤使用ngFor生成的列表," description"财产名称。列表是这样的对象:
[
{ code: 001, description: "Product 001 description" },
{ code: 002, description: "Product 002 description" },
{ code: 003, description: "Product 003 description" },
{ code: 004, description: "Product 004 description" }
]
我的功能:
seachFilterData(e) {
const query = e;
this.filterData.map((items) => Object.values(items).forEach(value => {
return Object.keys(value).filter(k => {
if (value.toLowerCase().includes(query.toLowerCase())) {
return items;
}
});
}));
}
HTML:
<input type="text" class="tokenfield-search" placeholder="search" [ngModel]="searchFilter" value="" (ngModelChange)="seachFilterData($event)">
<div class="tokenfield-list">
<ul>
<li *ngFor="let data of filterData | keys">
当我console.log(items)
过滤时,但列表没有变化。有什么想法吗?