import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
    name: 'searchAuto'
})
export class SearchAutoPipe implements PipeTransform {

    transform(items: any[], searchText: string , text: any): any[] {
        if (!items) return [];
        if (!searchText) return items;
        if (!text) return text;
        text = text.toLowerCase()
        searchText = searchText.toLowerCase();
        var menu = items.filter(it => {
            // console.log(it);
            return it[text].toLowerCase().includes(searchText);
        });
        if (menu.length != 0) {
            return menu
        }
    }

}
