blob: 7e017e8590541ee886870401b37fc093bac7e9ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'searchFilter',
})
export class SearchFilterPipe implements PipeTransform {
public transform(value, key: string, term: string) {
if (!term || !term.length) return value;
return value.filter((item) => {
if (item.hasOwnProperty(key)) {
let regExp = new RegExp(term, 'gi');
return regExp.test(item[key]);
} else {
return false;
}
});
}
}
|