简体   繁体   中英

setRoot() not working after dismiss modal in ionic 3

i tried to setRoot after dismiss modal in ionic 3, but its not working perfectly. i want to make root /opportunities/opportunities-detail change to opportunities/opportunities-unit after open and select modal value

its only works if i use main root navigation like this

this.app.getRootNav().setRoot('OpportunitiesUnitPage');

but i dont want to change my root before it, i just want to push new root after open the modal i tried this, but its not works

 this.navCtrl.push('OpportunitiesUnitPage', {});

this is the full code that i have done oppotunities-detail.ts

let modalQualifyVerify = this.modalCtrl.create('OpportunitiesNotifPage', {
       meta: this.meta,
       opportunity:this.opportunity,
       selection: this.savedSelection,
       status: 'unitSelect'}, {cssClass: 'select-modal-unit' });
     modalQualifyVerify.onDidDismiss(data => {
     });
     modalQualifyVerify.present();

oppotunities-notif.ts

changeUnit(){
this.viewCtrl.dismiss(null);
this.navCtrl.push('OpportunitiesUnitPage', {
  meta: this.meta,
  opportunity: this.opportunity,
  selection: this.savedSelection
});

}

can you guys helpp me how to figure it out? thankyou:)

I already found the aswer guys, i setroot after i dismiss the modal, this is the full code that i made

oppotunities-notif.ts

changeUnit(){
var dismissData = {status:'unitPage'};
this.viewCtrl.dismiss(dismissData);

}

opportunities-detail.ts

 let modalQualifyVerify = this.modalCtrl.create('OpportunitiesNotifPage', {
      meta: this.meta,
      opportunity:this.opportunity,
      selection: this.savedSelection,
      status: 'unitSelect'}, {cssClass: 'select-modal-unit' });
    modalQualifyVerify.onDidDismiss(data => {
      if(data.status == "unitPage"){
        this.navCtrl.push('OpportunitiesUnitPage', {
            meta: this.meta,
            opportunity: this.opportunity,
            selection: this.savedSelection
          });
      }
    });
    modalQualifyVerify.present();

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