aboutsummaryrefslogtreecommitdiffstats
path: root/stories/ng2-component-lab/pipes/search-filter-pipe.ts
blob: 5469eb4467b61545b4121411968d122d15df8aa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Pipe, PipeTransform } from '@angular/core';

@Pipe ({
    name: 'PipeSearchFilter',
})
export class SearchFilterPipe implements PipeTransform {
    public transform(value, text: string) {
        if (!text || !text.length) {
            return value;
        }
        return value.filter((item) => {
            return item.toLowerCase().indexOf(text.toLowerCase()) > -1;
        });
    }
}