Ionic - Error: Uncaught (in promise): removeView w

2019-01-23 23:57发布

My Ionic app was working fine and I haven't done anything to it but suddenly I am getting this error and I don't know why.

"Error: Uncaught (in promise): removeView was not found

9条回答
干净又极端
2楼-- · 2019-01-24 00:28

Deleting a component is not a solution to any problem.

Cause of issue: There are multiple calls to dismiss method of loading component.

Solution: While creating the loader, check if the loader instance is not already present, only then create another instance.

Similarly, while dismissing the loader, check if the loader instance does exists, only then dismiss it.

Code:

constructor(private _loadingCtrl: LoadingController){}

loading;

showLoading() {
    if(!this.loading){
        this.loading = this._loadingCtrl.create({
            content: 'Please Wait...'
        });
        this.loading.present();
    }
}

dismissLoading(){
    if(this.loading){
        this.loading.dismiss();
        this.loading = null;
    }
}
查看更多
Bombasti
3楼-- · 2019-01-24 00:29

Here is my simplest solution to this problem:

I have got this problems when implementing the LoadingController

Note: Don't initialize loader inside the construction (it works only first time and from second time you will get stuck with remove view not found problem)

loading:any;

this.loading=this.loadingCtrl.create({
        spinner:'bubbles',
        content:`Please wait..`
      });

I was displaying the loader while getting data from server Below is the working code

 gosignup(number:string){

    this.loading.present();//showing the loader
    //calling webservice 
    this.Authprovider.smsverify(number).subscribe(
      data=>{                  
        this.loading.dismiss();//to dismiss loader        
        if(data.json().msg=="success"){
           this.navCtrl.push(SignupPage,{
             user:this.Usersignup
           })
        }

        if(data.json().msg=="error"){
          this.showToastWithCloseButton("Invalid otp");
        }

      },

      err=>{
          this.loading.dismiss();
          this.showToast("Please try again later");
      },

      ()=>{
              this.loading.dismiss();//to dismiss loader
      }

      );



  }

Hope it will solve SO problems

查看更多
男人必须洒脱
4楼-- · 2019-01-24 00:34

For me, the problem was that I had

dismissOnPageChange: true

when I created the loadingCtrl.

The .dismiss() was being called too soon after the .present() (during local testing the api responds really fast) and it seems having that parameter caused the issue. Removing it solved it for me.

查看更多
登录 后发表回答