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 pro
I updated to the latest version @ionic/app-scripts 3.3.0 and this is also happening in my app.
I managed to solve it by deleting the LoadingController from my component.
Please try the below which worked for me
import { App } from 'ionic-angular';
export class PopoverPage {
constructor(public navCtrl: NavController
, public viewCtrl: ViewController
, public appCtrl: App) {
this.viewCtrl.dismiss().then(()=>{
setTimeout(()=>{
confirm.dismiss().then(()=>{
this.appCtrl.getRootNav().setRoot('DashboardPage');
})
},300)
})
}
}
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.
it says that you called to loading.dismiss() before load.presenet() ended. you should try
let a = this.loadingCtrl.create({content : 'hello world'})
await a.present();
..
.. // your code goes here..
...
a.dismiss()
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;
}
}