sanshine
sanshine

Reputation: 23

ionic2 in a modal page navigate to another page ?

When I push another page in my modal using this.navCtrl.push(TwoPage), the pushed page displays like this:

enter image description here

The modal was created as follows:

let modal = this.modalCtrl.create(OnePage);
modal.present();   

Upvotes: 1

Views: 2365

Answers (3)

Alessandro Ornano
Alessandro Ornano

Reputation: 35372

IONIC 3:

You should avoid to push directly from modal navigator, instead try to do:

constructor(
      private appCtrl: App,
      ...

Then , in you method do:

this.appCtrl.getRootNavs()[0].push(YourNextPage);

Upvotes: 0

guillermogfer
guillermogfer

Reputation: 372

Just to update, getRootNav() is deprecated and now you have to use:

this.app.getActiveNav().push(TwoPage);

but this will be also deprecated and the recommendation is to use getActiveNavs() which returns an array of active NavControllers, so at your own risk you could use it this way:

this.app.getActiveNavs()[0].push(TwoPage);

Upvotes: 0

Suraj Rao
Suraj Rao

Reputation: 29614

Check the Navigating from an Overlay Component section in the Ionic doc

Try in your modal:

import { App, ViewController } from 'ionic-angular';

The constructor: Inject App

 constructor(
      public viewCtrl: ViewController
      public app: App
    ) {}

Inorder to navigate,

this.app.getRootNav().push(TwoPage);

Upvotes: 5

Related Questions