[英]Ionic 2 disable Infinite scroll spinner
I have an infinite scroll working perfectly, however, when I get to the end of my data, the spinner still spins. 我有一个无限滚动,可以完美运行,但是,当我到达数据末尾时,微调器仍会旋转。 How do i stop the spinner?
我如何停止微调器?
As you can see, I am setting hasMoreData
to false
, but the spinner still spins. 如您所见,我将
hasMoreData
设置为false
,但微调器仍在旋转。
Thanks 谢谢
html html
<ion-infinite-scroll *ngIf="hasMoreData" (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
ts 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();
});
}
You need call function enable(false)
when data is end. 数据结束时需要调用函数
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);
}
} }
Just this already worked for me! 只是这已经为我工作了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.