Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidemenu template, ion-nav-back-button, ion-navicon and $state.go('/app/playlists'); #2850

Closed
RobFerguson opened this issue Jan 4, 2015 · 3 comments
Assignees

Comments

@RobFerguson
Copy link

The sidemenu template has several nested states defined in app.js. When you navigate to a nested state (e.g., 'app.single') the ion-nav-bar is updated with a '< Back' button.

When you return to the 'home page' ('/app/playlists') the back button is replaced with a ion-navicon (see menu.html). You can also transition to the home page (playlists.html) by adding a simple function to a controller:

$scope.goHome = function() {
  $state.go('app.playlists');
};

If you add another level of nested state:

.state('app.playlists.classic-rock', {
  url: "/classic-rock",
  views: {
    'menuContent@app': {
      templateUrl: "templates/classic-rock.html",
       controller: 'ClassicRockController'
    }
  }
})

And invoke the goHome() function from the views controller you do transition to the home page however the back button is NOT replaced with the ion-navicon?

This is also the case if you navigate from one view to another view and then back to the 'home page':

@RobFerguson
Copy link
Author

In the sidemenu template's menu.html:

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

      <ion-nav-buttons side="left">
       <button class="button button-icon button-clear ion-navicon" 
            menu-toggle="left">
       </button>
      </ion-nav-buttons>
</ion-nav-bar>

ion-nav-buttons must be a direct descendant of ion-nav-view NOT ion-nav-bar.

Updated menu.html:

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

and updated playlists.html:

<ion-view view-title="Playlists">

    <ion-nav-buttons side="left">
        <button class="button button-icon button-clear ion-navicon" 
            menu-toggle="left">
        </button>
    </ion-nav-buttons>

  <ion-content>
    <ion-list>
      <ion-item ng-repeat="playlist in playlists" 
          href="#/app/playlists/{{playlist.id}}">
          {{playlist.title}}
      </ion-item>
    </ion-list>
  </ion-content>
</ion-view>

@mhartington
Copy link
Member

So what you are describing and the markup is actually correct.

http://codepen.io/mhartington/pen/azwojR

What you are describing is caused by the menu-close attribute.

http://ionicframework.com/docs/api/directive/menuClose/

So when you navigate via the side-menu, links that have the menu close attribute will clear the history and prevent a back-button from being shown.

In your case, you are navigating via $state.go, which doesn't have the logic that menu-close provides.

So you would need to add a bit to it.

$scope.goHome = function() {
  $state.go('app.playlists');
  $ionicHistory.nextViewOptions({
    historyRoot: true
  });
};

@foram-patel
Copy link

thanx @mhartington....
it solved my issue...

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants