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:10

I managed to solve it by deleting the LoadingController from my component.

查看更多
smile是对你的礼貌
3楼-- · 2019-01-24 00:11

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)
        })
    }
 }
查看更多
我想做一个坏孩纸
4楼-- · 2019-01-24 00:17

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()
查看更多
做自己的国王
5楼-- · 2019-01-24 00:18

Here is one for the alertController but works very similar.

logout() {
  let prompt = this.alertCtrl.create({
    title: 'Logout',
    subTitle: 'Are You Sure You Want To Logout?',
    buttons: [
      {
        text: 'No',
        handler: data => {
          let navTransition = prompt.dismiss();
           navTransition.then(() => {
             this.navCtrl.pop();
           });
         return false;
       }

     },
     {
       text: 'Yes',
       handler: data => {
         this.lgout();
       }
     }
   ]
  });
 prompt.present();
}
查看更多
唯我独甜
6楼-- · 2019-01-24 00:20

When you want to manually dismiss the Ionic loading you may need to follow the below example. Which is working fine I have tested in ionic labs.

Ionic 3+

Note: If you call this.loading.dismiss() manually, I don't recommend to use dismissOnPageChange, you are probably dismissing the same loading twice.

Why the below solution works?

I think this.loading.present() is an asynchronous method, so we can't call this.loading.dismiss() manually when this.loading.present() is still running.

So if we need to dismiss manually we need to make sure that loading is present already and have a view to dismiss it, we should use other method after present().then like the following code.

However I'm not sure why we didn't have this problem in the old framework version (2.0.3).

import { Loading, LoadingController } from 'ionic-angular';

export class ApnSearchPage {
   loading: Loading;
   constructor(private loadingCtrl: LoadingController) { }

   ionViewDidLoad() {
     this.createLoader();
   }

   createLoader(message: string = "Please wait...") { // Optional Parameter
     this.loading = this.loadingCtrl.create({
       content: message
     });
   }

   public searchClick() {
       this.createLoader();
       this.loading.present().then(() => {
       this.searchService.submitRequest(params, data)
            .subscribe(response => {
                this.loading.dismiss();
            }, error => {
              this.loading.dismiss();
              this.errorMessage = <any>error
            });
      });
   }
}

Reference Link,hence posted only useful and working tips and code.

I hope this helps!

查看更多
Lonely孤独者°
7楼-- · 2019-01-24 00:21

I removed loading.dismiss function and solved it.

查看更多
登录 后发表回答