Back buttons for ionic sidemenu pages


#1

I have following items in ionic side menu list.

Home (contains nested states like books, games,etc.)
Profile
About

By default from profile or about pages there is no back button in nav bar and app exits on using androids hardware back button.

I want Profile and About page to go back to Home on tapping hardware back button (which is the standard way in most apps today) and I would also like to have back button in header nav bar that links to home.

How can I achieve this in ionic?


#2

You need to remove the menu-close attribute from the menu items that you want a back button to show on. This directive clears the navigation stack and sets the next view as the history root. This should give you your desired result.


#3

Thanks it works. After removing menu-close, backbutton is showing but side menu remains open so i added menu-toggle attribute to menu items to close the menu.

Is there any other option other then menu-toggle that can close the side menu ?


#4

Hi, I need this solution too. The side menu remain open. What is the proper way to have Back link and also close the side menu? Please advice, thank you.


#5

Hi, I just tried add menu-toggle=“left” and it works. Close the side menu plus with back button. Hope this help.


#6

You could add ng-click="toggleLeft()" to the menu item, and then define a function that toggles the menu:

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

Either way will close the menu.

$ionicSideMenuDelegate docs