Any way to -not- reset history stack on menu-close?

Is there a way to create links in the side menu that act as sub-pages to the root page, instead of each link becoming root pages themselves? I would like each of my pages to have a back button as needed, and no pages being viewed from the side-menu are getting one.

I’m aware that the menu-close directive causes the history stack to be reset due to a UI best practice guideline, and it seems I would like to go directly against that. I’ve tried using menu-toggle in place of menu-close, but that causes a weird double transition effect.

Thanks!

1 Like

You can put a ng-click on the menu item and use toggleLeft (or right depending on your sidemenu) to close it:

HTML:

<ion-item ng-click="closeMenu()" ui-sref="page2">Page 2</ion-item>

JS:

$scope.closeMenu = function() {
    $ionicSideMenuDelegate.toggleLeft();
}

Thanks Brandy. That comes close to what I want to achieve, but not quite. There’s still an issue of the page transitioning while the menu is closing, which looks awful.

What I need is to be able to use nav-clear to disable transitions on specific links, but that seems to reset the history stack in the same way menu-close does.

Hmm you can use $ionicHistory before navigating. This is the same thing menu-close does minus the history reset.

$ionicHistory.nextViewOptions({
        disableAnimate: true
});
1 Like

That worked perfectly, thank you!

1 Like