Stop infiniteScroll?



I am very much new to Ionic2 and trying to use Infinite Scroll with a web service using provider. Its working fine however i am not able to stop it if there is no data. I am following Ionic2 documentation at

This is my code in .TS file

doInfiniteGallery(): Promise<any> {
    console.log('Begin async operation');
    return new Promise((resolve) => {
	 this.authService.GetGallery(this.Num).subscribe(Result => {;
setTimeout(() => {
	for (var i = 0; i < this.AvlData.length; i++) {
          this.items.push( this.AvlData[i] );

        console.log('Async operation has ended');
      }, 500);
	  this.Num=this.Num + this.AvlData.length + 1;	
	  });	//subscribe end

I am using a provider to fetch data from website, this is the code in provider -

	return this.http.get("http://MYDOMAIN.COM/fetch.php?action=imagestitle&start="+count).map(res=>res.json());	

HTML File code as

<ion-item *ngFor="let item of items">
   <ion-col col-12 col-sm>

<ion-infinite-scroll (ionInfinite)="$event.waitFor(doInfiniteGallery())">

Problem here is that i am not able to STOP the infinite scroll. I changed the code in HTML as

 <ion-infinite-scroll *ngIf="!lastpage" (ionInfinite)="$event.waitFor(doInfiniteGallery())">

It worked but that spinner still shows.

I Googled and found that i need to use InfinateScroll.enable(false) however i am not able to put this in correct position inside function, i tried but it’s giving undefined error.

Can anyone please help me out ?



Hi, Anyone please, have some details about it?


There is no need here for making promises or using setTimeout().

<ion-infinite-scroll *ngIf="completed"

fetchMorePics(evt: InfiniteScroll): void {
  this.authService.getGallery(this.npics).subscribe((pics) => {
    if (pics.length > 0) {
      Array.prototype.push.apply(, pics);
      this.npics += pics.length;
    } else {
      this.completed = true;