如何解决如何在无限滚动功能中获取搜索栏的值
searchPublikasi(ev: any) {
// set val to the value of the searchbar
let val = ev.target.value;
this.publicationList.searchPublikasi(val).subscribe((publicationListData:any) => {
this.allPublication= publicationListData.data;
this.listDomain=this.allPublication[1];
})
}
doInfinite(infiniteScroll) {
console.log('Begin async operation');
this.page = this.page+1;
// set val to the value of the searchbar
let val = 'penduduk';
setTimeout(() => {
this.publicationList.searchPublikasi(val).subscribe((publicationListData:any) => {
for (let pub of publicationListData.data[1]) {
this.listDomain.push(pub)
}
});
console.log('Async operation has ended');
infiniteScroll.complete();
},1000)
}
<span *ngFor="let list of allPublication" color="dark">
<ion-label style="font-size: 1rem;text-align: right;padding-right: 2%;">
Menampilkan {{list.total}} Publikasi
</ion-label>
<ion-grid *ngFor="let pub of listDomain">
<ion-card (click)="launchPubDetailsPage(pub)">
<ion-row>
<ion-col size="1">
<ion-item>
<ion-thumbnail>
<ion-img [src]="pub.cover"></ion-img>
</ion-thumbnail>
</ion-item>
</ion-col>
<ion-col size="11" style="font-weight: bold;">
<ion-label color="danger" style="font-size: 1.1rem;">{{pub.rl_date}}</ion-label>
{{pub.title}}
<ion-label color="secondary" style="font-size: 1.1rem;">{{pub.size}}</ion-label>
</ion-col>
</ion-row>
</ion-card>
</ion-grid>
我真的很困惑,如何获取用户在搜索栏中输入的值并在 doInfinite 中使用它。在无限滚动中加载下一页时显示错误。我不能在 doInfinite 函数的离子搜索中使用关键字。谢谢。
解决方法
ts code
public searchVal = '';
constructor(){}
searchPublikasi(ev: any) {
// set val to the value of the searchbar
this.searchVal = ev.target ? ev.target.value : ev;
this.publicationList.searchPublikasi(val).subscribe((publicationListData:any) => {
this.allPublication= publicationListData.data;
this.listDomain=this.allPublication[1];
})
doInfinite(infiniteScroll) {
console.log('Begin async operation');
this.page = this.page+1;
// set val to the value of the searchbar
let val = 'penduduk'; // or you can user direct this.searchVal
setTimeout(() => {
this.publicationList.searchPublikasi(val).subscribe((publicationListData:any) => {
for (let pub of publicationListData.data[1]) {
this.listDomain.push(pub)
}
});
console.log('Async operation has ended');
infiniteScroll.complete();
},1000)
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。