$ionicNavBarDelegate and navigation history


i’m having problems with navigation history.

I have a simple configuration of state provider:

.state('offerte', {
  url: "/offerte",
  templateUrl: "partials/serviziPubblici/offerte.html", 
  controller: "OfferteCtrl",

.state('contatti', {
  url: "/contatti",
  templateUrl: "partials/serviziPubblici/contatti.html", 
  controller: "ContattiCtrl",
.state('home', {
  url: "/",
  templateUrl: "partials/home.html",
  controller: 'HomeCtrl',

i’d like to have the back button of the navbar naming the last $state visited,
but $ionicNavBarDelegate.getPreviousTitle() doesn’t work.

I have a new <ion-nav-bar></ion-nav-bar>
inside <ion-view title="..."></ion-view> of every template, because i need to have a customized navbar only in the home so i couldn’t put a general navabar for every state.

Hope you can help me,
thank you!

another thing: i put a console.log() inside my $scope.getPreviouseTitle()
and i’ve nothice that it’s called 4/5 times. This happens even with the ionic template app.
and i didn’t understand why.

  <ion-nav-bar class="bar-balanced">
  <ion-nav-back-button class="button-icon">
<div class="buttons right-buttons">


Seems to work fine in this example.


The fact that it’s called 4/5 times is due to Angular’s digest cycle.

This is by design and isn’t something to be worried about unless performance degrades.


yes but i don’t have a “menu” so i can’t do master.something and master.somethingother

are history navigation bind only to master > child?

i thought it was a general thing.


No, it’s not tied to master>child.

You can do this .


First of all thank you!
The problem is i don’t have a unique navbar. I need to insert a new navbar in every template because i have to customize one of them.

My situation is like in the Alternative usage in http://ionicframework.com/docs/api/directive/ionNavBar/

i changed a bit this (dunno why right buttons don’t stay right)


Well what are you changing?


i thought i made myself clear.

instead of having one “master” <ion-nav-bar></ion-nav-bar> and than for each <ion-view></ion-view> adding only the navbar buttons like this:

 <ion-nav-bar class="nav-title-slide-ios7 bar-positive"></ion-nav-bar>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
<script id="main.html" type="text/ng-template">
 <ion-view title="Page One">
   <ion-nav-buttons side="right">
     <a ui-sref="second" class="button button-clear">
       Page Two
      <h3>Page One</h3>

i need to have a navbar for every ion-view like this:

<script id="second.html" type="text/ng-template">
   <ion-view title="Page Two">
      <ion-nav-bar class="bar-positive">
             <button class="button button-icon" ng-click="goBack()"><i class="icon ion-arrow-left-c"></i>  {{getPreviousTitle() || 'Back'}} </button>
            <h3>Page Two</h3>

in that way the navigation history doesn’t work, like i show you here,
i always have a back label


But why do you need a nav bar for each view? What kind of customization are you doing that requires a new nav-bar each time?

Instead my don’t you use an ion-header-bar?


So in the end, i understood. What i needed was organize my routing differently.

Having one Main with no ion-nav-bar instead a ion-header-bar
and one ion-nav-bar for every starting point from Main childs.

.state(‘main’, {})
.state(‘contacts’ {abstract : true}, templateUrl:“navbar.html”)
.state(‘contacts.home’ {}).state('contacts.detail, {})

and so on.
Thank you for your patience.