0
votes
  1. App loaded in the root page (Page1).
  2. Click a button so a new root page is set (Page2).
  3. Click a button, a page is being pushed (Page3).
  4. Hit back button on the device.

What is the expected behaviour of the app? Does it navigate back to Page1 or Page2?

As I am serving the app in a browser, hitting back button on Chrome pops the pushed page so I am navigated back to Page2. But in the DevApp I am being navigated to Page1. Is DevApp really that inconsistent?

UPDATE It was a mistake. Hitting back button on browser does pop the page and direct me to Page1. How would I control the back button so that when it is pressed it only pop the active page?

1

1 Answers

0
votes

The behaviour in the app (runing on device) will be it going back to page 2 if you've pushed page 3. When you set the root to some page it clears que Ionic/Angular navigation history and starts a new one, so page 1 doesn't exists in your navigation stack anymore.

In the browser it'll create a navigation history and navigate back if you have lazy loaded your pages, if you haven't it'll not change the URL and so you'll be able to navigate back only in the app back button. (i'm not an expert so i don't know how to explain in a better way the navigation in browser).

So if you want to control so the browser back button only pops one page i sugest lazy loading your application or - in a quickier and easier way - having a back button somewhere in your page so you can navigate back.

Hope this helps.