ユーザーの検索クエリの入力をフィルタリングしようとしています。検索する特定の名前を入力すると、そのものだけが返されます。検索とフィルタリングのための省略コード
私はAngular2デモアプリケーション(http://mazzoangular2.azurewebsites.net/)を持っています。私は、単にアーティストの作品を検索する検索結果を返します。今すぐ入力された最初の文字を含むすべての絵を戻しています。あなただけpipeModiferの最初の文字と評価している、あなたのコードで
import { Pipe } from '@angular/core';
@Pipe({
name: 'find'
})
export class SearchPipe {
transform(pipeData, pipeModifier) {
return pipeData.filter((eachItem) => {
return
eachItem['name'].toLowerCase().includes(pipeModifier.toLowerCase()) ||
eachItem['shortname'].toLowerCase().includes(pipeModifier.toLowerCase());
});
}
}//End class SearchPipe
SearchPipe.prototype.transform = function (pipeData, _a) {
var pipeModifier = _a[0];
return pipeData.filter(function (eachItem) {
return
eachItem['name'].toLowerCase().includes(pipeModifier.toLowerCase()) ||
eachItem['shortname'].toLowerCase().includes(pipeModifier.toLowerCase());
});
}
あなたのコードに何が問題なのですか? – toskv
あなたはhttp://mazzoangular2.azurewebsites.netで遊ぶためにこのリンクに行くことができますが、問題は検索ロジックが直接入力された特定の名前にドリルダウンしていないようです。検索入力フィールドに提案された名前を入力する場合など。 –