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

@Pipe({
  name: 'datafilter'
})
export class DatafilterPipe implements PipeTransform {

  transform(items: any[], searchTerm?: string) {
    let filteredList: any[] = [];
    if (searchTerm) {      
      return items.filter(item => 
        Object.keys(item).some(k => item[k] != null && 
        item[k].toString().toLowerCase()
        .includes(searchTerm.toLowerCase()))
        );
    }
    else {
      return items;
    }
  }

}
