aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/autocomplete/autocomplete.pipe.ts
blob: bee24ab116b79b66acb12250fbb57ea082ea4cd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import { Pipe, PipeTransform } from '@angular/core';
import { IDataSchema } from './autocomplete.component';

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