整个 table 上的 Angular4 搜索过滤器功能

Angular4 search filter functionality on Entire table

这里我在 table 上实现了小型搜索过滤器,但我的要求是它应该搜索整个 table 不在页面内?

搜索

<label> Search FRom Table:</label> <input (change)="someval($event.target.value)">          


someval(value){
   let data=JSON.stringify(value);
   console.log(data.length);
   this.auction.find(e=>e.uniqueid=data);
   this.GetDashBoardData();
}
GetDashBoardData(){
    var somedata= this.globalService.getBasicInfoData();
    this.auctionRequest = {    
      "loginId": this.userdata.LoginID
    }; 
    return this.httpService.dashbordTheUser2(this.auctionRequest).subscribe((response) => {
      this.auction = response.data;
}

这里我稍微做了一些改动,比如当我在文本框中输入一些文本时,它会出现在 This.auction 的数组中,但我不知道如何在 [=24 中绑定它=]

<tr *ngFor="let value of pagedItems">
                     <td>{{value.name}}</td>

您可以试试这个解决方案

我已经在 stackblitz

上创建了一个演示

Search Pipe

transform(value: any, args?: any): any {
    if (!args) {
      return value;
    }
    return value.filter((val) => {
      let rVal = (val.id.toLocaleLowerCase().includes(args)) || (val.email.toLocaleLowerCase().includes(args));
      return rVal;
    })

}

html code

<tr *ngFor="let customer of users | customerEmailFilter:email;let i = index">
    <th scope="row">{{i+1}}</th>
    <td>{{customer.id}}</td>
    <td>{{customer.email}}</td>
</tr>

ts file code

users=[{
    id:'123',
    email:'abc@gmail.com'
  },{
    id:'1234',
    email:'xyz@hotmail.com'
  },{
    id:'12345',
    email:'jsgsbh@kk.com'
  },{
    id:'123456',
    email:'test@gmail.com'
}]