When does the back button show?


#1

Hello.
I would like to know what are the scenarios where back buttons actually appear.

I have these states :

.state('categories', {
    'abstract':true,
    url: '/categories',
    templateUrl: 'templates/categories.html'
  })

  .state('categories.posts', {
    url: '/:CategoryId',
    views: {
      'categories-posts': {
        templateUrl: 'templates/categories-posts.html',
        controller: 'CatPostsCtrl'
      }
    }
  })

Where I display posts belonging to a given category.

Then I have these states:

.state('posts', {
    abstract: true,
    url: '/posts',
    templateUrl: 'templates/posts.html'
  })
  .state('posts.details', {
    url: '/:PostId',
    views: {
      'posts-details': {
        templateUrl: 'templates/posts-details.html',
        controller: 'PostsCtrl'
      }
    }
  })

That displays the post once clicked on from the list of posts displayed in the category.

What I want is a back button from the post details to the post list inside the category.

Is it naturally achievable or should I hack the button myself?

Thank you.


#2

Have you included the correct directive:

  <!-- The nav bar that will be updated as we navigate -->
  <ion-nav-bar class="bar-positive">
    <ion-nav-back-button class="button-clear">
      <i class="ion-arrow-left-c"></i> Back
    </ion-nav-back-button>
  </ion-nav-bar> 

Here’s my Master-Detail pattern example: http://plnkr.co/edit/NN4cWr?p=info


#3

@Gajotres
in index.html I have this:

<ion-nav-bar class="bar-stable bar-positive">
      <ion-nav-back-button>
      </ion-nav-back-button>
    </ion-nav-bar>

Also you’re not transiting from nested states with both different abstract parents? Is that a thing?


#4

I figured out the problem,
it’s this code:

<ion-tabs class="tabs-icon-top tabs-color-active-positive">

    <!-- Dashboard Tab -->
    <ion-tab title="Status" icon-off="ion-ios-pulse" icon-on="ion-ios-pulse-strong" ui-sref="home">
        <ion-nav-view name="categories-posts"></ion-nav-view>
    </ion-tab>

</ion-tabs>

apparently the tabs screw the history or don’t even use them