使用侧边菜单和选项卡时的离子历史堆栈 [英] Ionic history stack when using side menu and tabs

查看:76
本文介绍了使用侧边菜单和选项卡时的离子历史堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用侧边菜单和标签时,我遇到了离子及其历史堆栈的麻烦。

I am having some troubles with ionic and its history stack when using side menus and tabs.

我在这里创建了一个plunker示例: http://embed.plnkr。 co / XK6seY9mDypTW6GcsCpj / preview

I created a plunker example here: http://embed.plnkr.co/XK6seY9mDypTW6GcsCpj/preview

要解决问题的步骤:


  1. 打开侧边菜单

  2. 导航至主列表

  3. 选择其中一项

  4. 您将被重定向到详细信息页面的常规数据选项卡

  1. Open side menu
  2. Navigate to "Master List"
  3. Choose one of the items
  4. You'll get redirected to the general-data-tab of the detail page

问题是没有后退按钮由离子本身显示在导航中。我创建了一个自己的后退按钮,调用 $ ionicGoBack($ event)来查看离子是否具有历史堆栈。但是当单击此按钮时,您会看到离子不会导航回主列表,而是保留在详细信息页面的常规数据选项卡上。

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?

非常感谢您的帮助!

祝你好运

推荐答案

这是因为菜单关闭指令重置历史堆栈(如此处所述)。

This is due to the fact that the menu-close directive resets the history stack (as explained here).

如果您从元素中删除menu-close,那么您会保留历史记录,但会丢失一些预期的行为。

If you remove "menu-close" from your elements, then you keep the history, but loose some of the expected behaviour.

作为一种解决方案,您可以开发自己的指令(比如说menu-close-keep-history)来替换菜单关闭指令。

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();
                }
            });
        }
    };
}]);

这应该可以解决问题。

这篇关于使用侧边菜单和选项卡时的离子历史堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆