File

libs/core/src/lib/pipes/matchLabel/match-label.pipe.ts

Metadata

Name matchLabel

Methods

transform
transform(value: any[], args?: string)
Parameters :
Name Type Optional
value any[] No
args string Yes
Returns : any[]
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'matchLabel'
})
export class MatchLabelPipe implements PipeTransform {

  transform(value: any[], args?: string): any[] {
    if (value && args) {
      return value.filter(e => e.label.toLowerCase().indexOf(args.toLocaleLowerCase()) >= 0);
    }
    return value;
  }

}
// TODO: use generics (MatchLabelPipe<T extends { label: string }>) and replace any, wait until error handling in angular language is improved (should be the case in Angular 9)

result-matching ""

    No results matching ""