ionic-framework: v2 : ion-navbar does not show back button in ion-tabs page
Short description of the problem:
Since v2 beta 10 ion-navbar does not show back button in ion-tabs page.
What behavior are you expecting?
If there is a possibility to go back to another view from an ion-tabs base page, it should display the back button and not the menu button.
Steps to reproduce:
- Create a simple app : A left menu, a simple page that push an ion-tabs page with the following toolbar :
<ion-navbar>
<button menuToggle="left">
<ion-icon name="menu"></ion-icon>
</button>
</ion-navbar>
- Navigate to it and it will show a menu button that does not allow to go back. (it triggers the menu)
Which Ionic Version? v2 beta 10
Run ionic info
from terminal/cmd prompt: (paste output below)
Your system information:
Cordova CLI: You have been opted out of telemetry. To change this, run: cordova telemetry on. 6.2.0
Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.1 Ionic Framework Version: 2.0.0-beta.10 Ionic CLI Version: 2.0.0-beta.32 Ionic App Lib Version: 2.0.0-beta.18 OS: Distributor ID: Ubuntu Description: Ubuntu 16.04 LTS Node Version: v6.3.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 25 (5 by maintainers)
I just saw @jgw96 closing comment to try using segments instead, but I did find a solution building on @mordka answer.
I found this StackOverflow answer about overriding the back button click http://stackoverflow.com/questions/38906715/ionic-2-generated-back-button-click-event
So by using css to force the back button to be displayed you can override the back button click event and dismiss the parent (Tabs) view controller using:
this.nav.parent.viewCtrl.dismiss();
In your TabPage.ts
If anynone’s interested in having the back button and using tabs here’s a simple css hack:
Would be nice to have
hideBackButton="false"
directive working on nav-bar (docs) .Hello all! I am going to be closing this issue as we only plan on supporting tabs as the root page at this time and using segments should fix the issue here. @fdelayen If you have any issues using segments feel free to hit up our forum. Thanks for using Ionic!
Thanks to all who provided this solution. Works like a charm! I disagree with others who don’t see this configuration as useful. A list of buttons that each takes you to a tabs-based detail page for the corresponding entity is very intuitive for what we are trying to do. Having a back-button on the tabs-based detail page to return to the list makes perfect sense to our users. Furthermore, tabs-based navigation on the detail pages is highly preferable to segments, so thanks again to those who provided the workaround!
@mjwheatley I have a small addition to anyone who might have the same problem as I did: In Ionic 3.10 default tabs template doesn’t have navbar component and it makes
navBar
undefined
. So code from TabPage.ts have to go to child components. E.g. my home.ts looks like this:great !
Thank you @zakton5 @jgw96 @mpaland for your answers. I have the same structure as zakton, my root page is a list of things, and when I click on this thing, I have many informations to display in categories so it definitely cannot be my root page and using segments is a bit tricky and we will need a lot of refactoring 😞
That’s the thing @mpaland, the tabs page isn’t necessarily always going to be the root of an application. I myself have this same issue. My root page is a list, and then when I click an item I push a tabs page onto the nav stack because each item has a LOT of content that needs to be displayed in different categories, which is why I use tabs. It’s really the best for my situation. Ionic 2 should have support for non-root tab pages