0 angular2-forms angular2-filtering angular angular4-forms
在这里,我在表格上实现了小型搜索过滤器,但我的要求是它应该搜索整个表格而不是页面内?
搜索
<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;
}
Run Code Online (Sandbox Code Playgroud)
在这里我稍微改变一下,就像当我在文本框中输入一些文本时,它会在This.auction数组中输入 ,但我不知道如何在表中绑定它
<tr *ngFor="let value of pagedItems">
<td>{{value.name}}</td>
Run Code Online (Sandbox Code Playgroud)
您可以尝试这个解决方案
我在stackblitz上创建了一个演示
搜索管道
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;
})
}
Run Code Online (Sandbox Code Playgroud)
html代码
<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>
Run Code Online (Sandbox Code Playgroud)
.ts 文件代码
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'
}]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13174 次 |
| 最近记录: |