我有一个完美的无限卷轴,然而,当我到达我的数据结束时,微调器仍然旋转。我如何阻止微调器?
正如您所看到的,我将hasMoreData
设置为false
,但旋转器仍在旋转。
由于
HTML
<ion-infinite-scroll *ngIf="hasMoreData" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
TS
doInfinite(infiniteScroll: InfiniteScroll) {
this.firstResult += this.MAX_RESULTS;
var promise: Promise<EmployeeModel[]>;
promise = this.employeeService.getEmployeeRangeSearch(this.firstResult, this.MAX_RESULTS, this.latitude, this.longitude, this.maxDistance, this.miles, this.searchQuery);
promise.then((employeeModels: EmployeeModel[]) => {
for (var index = 0; index < employeeModels.length; index++) {
this.employeeModels.push(employeeModels[index]);
}
if (employeeModels.length === 0) {
infiniteScroll.enable(false);
this.hasMoreData = false;
} else {
infiniteScroll.enable(true);
this.hasMoreData = true;
}
infiniteScroll.complete();
});
}
答案 0 :(得分:0)
数据结束时需要调用函数enable(false)
。
doInfinite(infiniteScroll) {
// Do your process
// ..
//if you no longer have data, usually in the asynchronous response of your call
if(hasMoreData){
infiniteScroll.enable(false);
}
}
这已经对我有用了!