Hi there,
hope you’re enjoying Ionic 4 like I do But I found a question for you on my journey building a little store administration.
Pre-Story for the Question
It’s a page based (not tab based) app.
-
Starting simply on the “Homepage”
-
A click in sidemenu and navigating with
this.navController.navigateForward('/search-products/0')
to a products listing page -
I got a list here now. Click on an item for an editing formular navigates to
this.navController.navigateForward('/edit-product')
Now the excelent working pain: When I “save” the changes on the edit formular of the 3. step above, I needed to get back explicitly to ‘/search-products/1’. This is no problem, when the user clicks on save button and the event handler calls
this.navController.navigateBack('/search-products/1')
(please notice the difference of the first value)
The Problem
Everything nice and dandy But … what, if the user pushs his back button on the phone or the back button in the app or even the browser when ionic serve
-ing? Then I allthough needed to get “back” to '/search-products/1'
, but this navigation path was not in the above stack … It was navigating back to /search-products/0
…
The Question
How to do that? How to change the content on the navigation stack?
The workaround I used so far
This way I’m using works “excelente”, but it doesn’t feel or even seem to be the right way:
- Again: Starting simply on the “Homepage”
- A click in sidemenu and navigating with
this.navController.navigateForward('/search-products/0')
to page
now the difference …
- I got a list here now. Click on an item for an editing formular navigates to
this.navController.pop().then(() => { // Going back to Homepage
this.navController.navigateForward('/search-products/1').then(() => { // come back with other parameter
this.navController.navigateForward('/edit-product').then(() => { // and NOW go to edit formular
// do stuff here ...
});
});
});
It looks really funny when the pages are changing quickly like an automated bot using the app, but … naaaaah … This is not the right way, I feel that. No other app was acting like this I’ve seen ever before, so … How do I solve this?
Thank you for any help and sorry for the novel I wrote …
Big kisses