特定のクエリに基づいてオブジェクトの配列を除外するパイプを作成しました。それはうまく機能しますが、可能であれば、入力のキーアップイベントに追加するのではなく、このパイプに直接デバウンス機能を追加したいと考えています。
解決策を探していますが、探しているものに固有のものを見つけることができないようです。
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'filterBy'
})
export class FilterByPipe implements PipeTransform {
transform(value: any, args: string[]): any[] {
if (!args[0]) {
return value;
}
else if (value) {
return value.filter(item => {
// TODO: Allow args[1] to be null, therefore searching in all object properties
if ((typeof item[args[1]] === 'string' || item[args[1]] instanceof String) && (item[args[1]].toLowerCase().indexOf(args[0].toLowerCase()) !== -1)) {
return true;
}
});
}
}
}
このパイプでこれをどのように実装するかについてのアイデアはありますか?