diff options
Diffstat (limited to 'vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts')
-rw-r--r-- | vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts b/vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts new file mode 100644 index 00000000..1ff83676 --- /dev/null +++ b/vid-webpack-master/src/app/shared/pipes/data-filter.pipe.ts @@ -0,0 +1,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; + } + } +} |