簡體   English   中英

Ionic 2禁用無限滾動微調器

[英]Ionic 2 disable Infinite scroll spinner

我有一個無限滾動,可以完美運行,但是,當我到達數據末尾時,微調器仍會旋轉。 我如何停止微調器?

如您所見,我將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();
    });
  }

數據結束時需要調用函數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);
  }

}

只是這已經為我工作了!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM