Skip to content

Instantly share code, notes, and snippets.

@Streeterxs
Created June 20, 2020 14:18
Show Gist options
  • Save Streeterxs/b8d1959043fc432d53a98e360c1ce663 to your computer and use it in GitHub Desktop.
Save Streeterxs/b8d1959043fc432d53a98e360c1ce663 to your computer and use it in GitHub Desktop.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'filterNgxMultiselect'
})
export class FilterNgxMultiselectPipe implements PipeTransform {
transform(arrayNgxMultiselect: {key: string, value: string | number}[], stringToFilter: string): any {
return !!arrayNgxMultiselect ?
arrayNgxMultiselect.filter(item => `${item.value}`.toLowerCase().trim().includes(stringToFilter.toLowerCase().trim()) || item.key.toLowerCase().trim().includes(stringToFilter.toLowerCase().trim())) :
arrayNgxMultiselect;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment