File

src/lib/pipes/pipe-list-filter/pipe-list-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: 'pipeListFilter',
})
export class PipeListFilterPipe 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)
        && item[key] && (`${item[key]} `).toLocaleLowerCase().includes(term.toLocaleLowerCase())))
    // new RegExp(`^${term}$`, 'gi').test(item[key])

  }

}

results matching ""

    No results matching ""