blob: 1ff8367625e639b6254a6656fe7f3321cf4ccd77 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/**
* Created by cp2122 on 1/4/2018.
*/
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'dataFilter'
})
export class DataFilterPipe implements PipeTransform {
keys = [];
transform(items: any, args: string): any {
if (items != null && items.length > 0) {
let ans = [];
if (this.keys.length === 0) {
this.keys = Object.keys(items[0]);
}
for (let i of items) {
for (let k of this.keys) {
if (i[k] !== null && i[k].toString().match('^.*' + args + '.*$')) {
ans.push(i);
break;
}
}
}
return ans;
}
}
}
|