File

src/lib/pipes/pipe-filter/pipe-filter.pipe.ts

Metadata

Methods

transform
transform(value: any, keys: string, term: string)
Parameters :
Name Type Optional
value any No
keys string No
term string No
Returns : string
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'pipeFilter'
})
export class PipeFilterPipe implements PipeTransform {

  transform(value: any, keys: string, term: string): string {
    if (!term) {
      return value;
    }
    return (value || []).filter((item: any) => keys.split(',')
      .some(key => item.hasOwnProperty(key) && new RegExp(`^${term}$`, 'gi').test(item[key])));

  }

}

results matching ""

    No results matching ""