question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v2 : ion-navbar does not show back button in ion-tabs page

See original GitHub issue

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:

  1. 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>
  1. 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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:25 (5 by maintainers)

github_iconTop GitHub Comments

21reactions
mjwheatleycommented, Feb 21, 2017

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

import {OnInit, ViewChild} from '@angular/core';
import {NavController, Navbar} from 'ionic-angular';

export class TabPage implements OnInit {
    @ViewChild(Navbar) navBar:Navbar;

    constructor(public nav:NavController) {
    }

    ngOnInit() {
    }

    ionViewDidLoad() {
        this.navBar.backButtonClick = (e:UIEvent) => {
            console.log("Back button clicked");
            this.nav.parent.viewCtrl.dismiss();
        };
    }
}
9reactions
mordkacommented, Aug 26, 2016

If anynone’s interested in having the back button and using tabs here’s a simple css hack:

//tab1.html (root page)
 <ion-navbar class="force-back-button">
//css
.force-back-button .back-button {
  display: inline-block;
}

Would be nice to have hideBackButton="false" directive working on nav-bar (docs) .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic nav-back-button not showing up - Stack Overflow
I'm currently facing the problem that my back button is not showing up. In my events tab, I allow people to click on...
Read more >
Ion-nav-back-button doesn't appear with my project structure?
My problem is that when i navigate from home state to user.tab1 state, the back button does not appear in navbar, how can...
Read more >
ion-back-button-tabs - npm
Start using ion-back-button-tabs in your project by running `npm i ion-back-button-tabs`. There are no other projects in the npm registry ...
Read more >
Ionic Component Documentation
Buttons are simple components in Ionic, can consist of text, an icon, ... If your page has an <ion-navbar> , a back button...
Read more >
Navbar missing back button when using Tabs in a child page
tab-root-back.page'; import { TabsContainerPage } from '. ... REAL CODE SHOULD NOT TRANSPILE IN THE BROWSER transpiler: 'ts', typescriptOptions: { tsconfig: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found