Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
742 views
in Technique[技术] by (71.8m points)

ionic2 - Ionic - Error: Uncaught (in promise): removeView was not found

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...