No back button in your Ionic header?

A few months ago I wrote up a quick article about titles not correctly updating in Ionic V1 apps (Is your Ionic View title not updating?). Today I've run into another little issue with the header. I was working on a very quick demo for a presentation tonight and had an app with a grand total of two views - a master list and detail.

Everything was working fine, but then I noticed I didn't have a back button when looking at the detail view. As far as I could tell, my code was fine. Here's what I had in the index.html file:


<ion-nav-bar>
		<ion-nav-back-button>Back</ion-nav-back-button>
</ion-nav-bar>

<ion-nav-view></ion-nav-view>

And each view was pretty simple as well. You can see the problem in action at this CodePen: http://codepen.io/cfjedimaster/pen/WxpPap. (I apologize for the formatting in the code - I was cutting and pasting rather quickly.)

I brought it up in the Slack chat and Mike Hartington came to the rescue rather quickly. Turns out the fix was... applying a class. Seriously. Even though the header has a class by default, if you don't explicitly specify one, then the back button won't show up. Literally - the fix is just this:


<ion-nav-bar class="bar-royal">
		<ion-nav-back-button>Back</ion-nav-back-button>
</ion-nav-bar>

<ion-nav-view></ion-nav-view>

You can see this working in a CodePen Mike made for me: http://codepen.io/mhartington/pen/YWZBdK.

Obviously I think this is - well - bunk (grin) - so I'll filed a bug report for it here: Back button will not show up if you do not specify a class for the nav bar.

And in case you're curious - here is the "Before" picture of this mission-critical Enterprise demo:

And here is the "After" picture:

Archived Comments

Comment 1 by Cristian Muscalu posted on 11/25/2016 at 9:26 AM

In my case the bar shows up, but no arrow.

Comment 2 (In reply to #1) by Raymond Camden posted on 11/25/2016 at 2:28 PM

Best I can suggest is filing a bug report then. Sorry!

Comment 3 (In reply to #1) by RandomUser posted on 11/28/2016 at 12:39 AM

If you're using tabs in your ionic application... the back button disappear if you move to a non-tab screen... I'm dealing with that issue at the moment. Seems like the answer will be to set the back button as an anchor.

Comment 4 by Mahiraj Singh Chufal posted on 12/7/2016 at 10:05 AM

The back button is there, it's not visible because the color of nav-bar and back button is same(which is white)

Comment 5 (In reply to #4) by Raymond Camden posted on 12/7/2016 at 12:29 PM

Ok. Same result though - it isn't visible so it might as well be not there. ;)

Comment 6 (In reply to #5) by Mahiraj Singh Chufal posted on 12/7/2016 at 4:39 PM

I checked by changing the color of nav bar, it was there..

Comment 7 (In reply to #6) by Raymond Camden posted on 12/7/2016 at 4:56 PM

I'm not disputing you. :) Just saying that to the naked eye, it appears missing, and this is how I fixed it.