简体   繁体   中英

Error when pull down for refreshing in Ionic3

hey I am trying to refreshing my product list by pulling down in ionic. First time it works but after that it gives this error

Error: Uncaught (in promise): removeView was not found
    at c (http://localhost:8101/build/polyfills.js:3:19752)
    at c (http://localhost:8101/build/polyfills.js:3:19461)
    at http://localhost:8101/build/polyfills.js:3:20233
    at t.invokeTask (http://localhost:8101/build/polyfills.js:3:15660)
    at Object.onInvokeTask (http://localhost:8101/build/vendor.js:5125:33)
    at t.invokeTask (http://localhost:8101/build/polyfills.js:3:15581)
    at r.runTask (http://localhost:8101/build/polyfills.js:3:10834)
    at o (http://localhost:8101/build/polyfills.js:3:7894)

My code for refreshing content is For HTML

<ion-refresher (ionRefresh)="doRefresh($event)">
        <ion-refresher-content  pullingIcon="arrow-dropdown"
        pullingText="Pull to refresh"
        refreshingSpinner="circles"
        refreshingText="Refreshing..."></ion-refresher-content>
    </ion-refresher>

In TS File

doRefresh(refresher) {
    console.log('Begin async operation', refresher);

    let loading = this.loadingCtrl.create({
      spinner: 'hide',
      content: `<img src="./assets/imgs/gif.svg" class="h15" />`,
    });
    this.service.getBrand().then((response:any)=>{
      loading.dismiss();
      this.brandlist = response;
    });
    this.serv.getProductList(this.sub_categoryes,this.filterCopy,this.newarrival,this.brand).then((response:any)=>{
      loading.dismiss();
      console.log(response);

      this.productlist = response;
      this.tmp_arr=response;
    });
    loading.present();
  }

When you call dismiss manually, you need to wait until loading.present() is resolved

 this.loading.present().then(() => {
    this.service.getBrand().then((response: any) => {
        loading.dismiss();
        this.brandlist = response;
    });

    this.serv.getProductList(this.sub_categoryes, this.filterCopy, this.newarrival, this.brand).then((response: any) => {
        loading.dismiss();
        console.log(response);

        this.productlist = response;
        this.tmp_arr = response;
    });

});

Check this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM