angular2 forms - Search filter in data table in Angular 2 -
i displaying json data in table has 3 columns , under each of these column have search text box user can search name , phone, age.below code.
import { pipe, pipetransform } '@angular/core'; @pipe({ name: 'namefilter', pure: false }) export class namefilterpipe implements pipetransform { transform(items: any[], searchterm: any): any[] { if (!searchterm) return items; return items.filter(function(item){ if(item.fullnme == null){ return null; }else { return item.fullnme.tolowercase().includes(searchterm.tolowercase()); } }) } }
below html code
<td class="input-cell"> <input type="text" class="form-control form-textbox input-text" id="lender_name" [(ngmodel)]="searchterm" style="width: auto;"> <span class="glyphicon glyphicon-search search-glyph"></span> </td>
my question "as having 3 different search text boxes, creating 3 different [(ngmodel)] , 1 name, 1 age , phonenumber 3 different pipes same logic[other changing ngmodel].is there way can use single filter 3 textboxes ?"
wiki
Comments
Post a Comment