I am having some troubles with ionic and its history stack when using side menus and tabs.
I created a plunker example here: http://embed.plnkr.co/XK6seY9mDypTW6GcsCpj/preview
Steps to follow to get to the problem:
The problem is that there's no back-button displayed in navigation by ionic itself. I created an own back button that calls $ionicGoBack($event) to see whether ionic has the history stack or not. But when clicking this button you'll see that ionic does not navigate back to the master-list, instead you'll stay on the general-data-tab of the detail page.
Can anyone tell me what the problem is? I am aware of tabs having their own history stack, nevertheless the tab should know its ancestor, or am I wrong?
Many thanks in advance for your help!
Best regards
Adding Tabs Bar in Ionic Application The tab navigation is created by adding the ion-tabs having ion-tab-bar inside it which creates a tab bar on position defined in the slot property. Each tab button is created using the ion-tab-button with tab property which is the path of tab page resulting navigation.
All tabs can be changed by setting the value of tabsLayout on the <ion-tabs> element, or in your app's config. For example, this is useful if you want to show tabs with a title only on Android, but show icons and a title for iOS.
This is due to the fact that the menu-close directive resets the history stack (as explained here).
If you remove "menu-close" from your elements, then you keep the history, but loose some of the expected behaviour.
As a solution, you can develop your own directive (let's say "menu-close-keep-history") to replace the "menu-close" one.
myModule.directive('menuCloseKeepHistory', ['$ionicHistory', function($ionicHistory) {
return {
restrict: 'AC',
link: function($scope, $element) {
$element.bind('click', function() {
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
if (sideMenuCtrl) {
$ionicHistory.nextViewOptions({
historyRoot: false,
disableAnimate: true,
expire: 300
});
sideMenuCtrl.close();
}
});
}
};
}]);
This should do the trick.
Well, instead of custom directive, one can use
menu-toggle
instead of
menu-close
When you use
menu-toggle
ionic keeps track of your navigation history
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With