Why Back-Button not showing when changing between two views?


#1

Hello all.

If i go from my SideMenu, to one button, (eg. Preferences, help, or profile) I want that this view shows the back button, to come back to the prev view. The back-button only shows up when navigating in the same view, and same controller.

I have this:

    .state('tabs.categories',{
      url: '/categories',
      views: {
        'cat-tab': {
          templateUrl: 'templates/categories.html',
          controller: 'ListController'
        }
      }
    })

    .state('edit_profile', {
        url: '/edit_profile',
        templateUrl: 'templates/edit_profile.html',
        controller:  'EditUserController'
    })

So i want to go from the welcoming Tab.categories view, to Profile. And there, have this back button to come back to this welcome view, categories.

I have in index.html the tags:

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

As I said, works between some views, but not in this case.

I’ve seen forums where people hard-code this, manually programming a button, but Im sure there must be a way where this back-button shows up among different Controllers. Right??

$ionicNavBarDelegate.showBackButton(true); didn’t work either. :confused:

Any recomendations?


#2

Well, by now I cooked the button myself. I thought this would be done automatically by Ionic, whilst moving between views.

I created the following button:

  <ion-nav-buttons side="left">
    <button class="button button-clear" ng-click="myGoBack()" >
          <i class="icon ion-ios-arrow-back"></i> Back
    </button>
  </ion-nav-buttons>

And then, this is the function within the Controller:

$scope.myGoBack = function() {
       window.history.back();
};

Little patchs. :slight_smile: