filter.pipe.ts
1.21 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'filter'
})
export class FilterPipe implements PipeTransform {
transform(value: any, filterString: string, propName: any): any {
console.log('propName: ', propName);
if (value.length === 0) {
return value;
}
const resultArray = [];
for (const item of value) {
// console.log('item: ', item);
var st = '';
//st = item['team'].toLowerCase() + item['COMMENT'].toLowerCase() + item['custgroupName'].toLowerCase() + item['STATUS'].toLowerCase() ;
if (item['team']) {
st += item['team'].toLowerCase();
}
if (item['COMMENT']) {
st += item['COMMENT'].toLowerCase();
}
if (item['custgroupName']) {
st += item['custgroupName'].toLowerCase();
}
if (item['STATUS']) {
st += item['STATUS'].toLowerCase();
}
if (item['type']) {
st += item['type'].toLowerCase();
}
var string2 = filterString.toLowerCase();
if (st.indexOf(string2) > -1) {
resultArray.push(item);
}
}
// if(resultArray === []){
// return resultArray.push(txt);
// }else{
return resultArray;
}
}