0
私のページに検索フィルターを設定したいと思います。しかし、それは常にundefinedを返すように見えます。イオン2:検索フィルターは未定義です
filterItems(searchTerm) {
this.category.forEach((item) => {
return item.data.filter((data) =>{
data.title.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1;
})
});
}
setFilteredItems() {
this.searchControl.valueChanges.debounceTime(500).subscribe(search => {
this.searching = false;
this.loadcategory = this.filterItems(this.searchTerm);
if (this.searchTerm == "") {
this.loadcategory = [];
this.searchresultcount = "0";
} else {
this.loadcategory;
console.log(this.loadcategory)
}
});
}
は私が(this.loadcategory)CONSOLE.LOGが、どうやらそれはのようにundefinedを返します。以下は、私の活字体です。私のコードのどこかにどこかでエラーがありますか?どんな助けでも大歓迎です。
をあなたは、これはパイプがために作られているものであるパイプの原因を作成する必要があります。
this.category
を想定し はしてみてください、配列です。ここで例を見ることができますhttps://github.com/VadimDez/ng2-filter-pipe/blob/master/src/ng2-filter.pipe.ts – misha130テンプレートで 'searchTerm'をどのように使いますか? –