import {Pipe, PipeTransform} from '@angular/core';
import {DomSanitizer} from '@angular/platform-browser';

/*****************
 * 属性精准过滤
 */
@Pipe({
  name: 'attrFilter'
})

export class AttrFilterPipe implements PipeTransform {

  constructor() {

  }

  transform(array: any, args: {}): any {
    if (array === undefined) {
      return [];
    }

    const rArray = [];
    for (const v of array) {
      for (const s in args) {
        if (args[s] === undefined || (v[s] !== undefined && (v[s] + '') === (args[s] + ''))) {
          rArray.push(v);
          break;
        }
      }
    }
    return rArray;
  }
}
