I am working in an ionic 4 project, and I want to navigate from modal to another page. I have tried:
this.router.navigate(['another']);
in my function and it doesn't work.
Asked
Active
Viewed 2,247 times
2

Ivan Kaloyanov
- 1,748
- 6
- 18
- 24

Lovasoa Ilay
- 21
- 3
1 Answers
0
What about setting another page below the modal and closing the opened modal?
Something like this:
navigateToPage(){
this.navCtrl.goForward('/page') // change page below modal
this.viewCtrl.dismiss(); // close modal
}

Eve Edomenko
- 421
- 1
- 3
- 13
-
What is nav in the second line of your code? I have tried your answer and there is an error according to nav syntax and viewCtrl syntax. I have yet import the ModalController – Lovasoa Ilay Jan 04 '19 at 14:02
-
nav: NavController and viewCtrl: ViewController you both have to import them and set them into your constructor. Hope this helps :) – Eve Edomenko Jan 04 '19 at 14:22
-
I work in ionic 4 project, and it doesn't work, there is an error according to push syntax. It says "the property push doesn't exist in the 'NavController type'" – Lovasoa Ilay Jan 04 '19 at 14:31
-
Sorry, I missed that it is not available on ionic4. Then it should be this.navCtrl.goForward('/page');. You can also look it up here: https://stackoverflow.com/questions/51828017/navcontroller-doesnt-work-in-ionic-4 – Eve Edomenko Jan 04 '19 at 14:52
-
It works! Thank you very much for your link reference, I have solved it. – Lovasoa Ilay Jan 04 '19 at 15:13
-
2The provided solution only works if I want to close the modal. What if I want to show a detail page of an item with the intent of returning to the modal. In my case the modal is an item selection page where the items have a "show details page"-button. Any ideas how to cater for this use case? – Eraldo Feb 05 '19 at 17:57