从另一个选项卡导航到子视图时无法回到父视图视图、选项卡

2023-09-13 05:20:55 作者:栖竹

我有一个使用离子标签的应用;我的问题的一个简单的例子可以重现有的。

I have an application that uses Ionic tabs; a simple example of my problem can be reproduced there.

有两个标签:首页设置

在状态管理器,有一个单一的顶层(摘要)状态标签。嵌套的 tabs.home 状态描述首页设置页。嵌套的 tabs.settings 状态是抽象的,包含两个嵌套的状态: tabs.settings.index tabs.settings.sub 。前者描述了设置标签,后者显示我的设置设置页(一个很简单的例子,一个子视图这种设置可以在 UI路由器维基)。

In the state manager, there is a single top-level (abstract) state tabs. The nested tabs.home state describes the home tab. The nested tabs.settings state is abstract and contains two nested states: tabs.settings.index and tabs.settings.sub. The former describes the settings tab, and the latter shows a sub-view of my settings tab (a very simple example of this setup can be found on the UI router wiki).

首页标签提供了一个按钮导航到直接在 tabs.settings.sub 状态(它使用 $ state.go(),但使用时的行为是一致的 UI-SREF )。

The home tab offers a button to navigate to the tabs.settings.sub state directly (it uses $state.go(), but the behavior is the same when using ui-sref).

问题是,导航到该 tabs.settings.sub 状态,我的 tabs.settings.index 之后状态是无法访问从现在开始:点击设置标签总是使用 tabs.settings.sub 状态

The problem is that after navigating to this tabs.settings.sub state, my tabs.settings.index state is inaccessible from now on: clicking the settings tab always uses the tabs.settings.sub state.

我能想到的两种方法要回父视图(即 tabs.settings.index 状态),但我不知道如何实现它们,并因此不它是否是可行的:

I can think of two approaches to get back to the parent view (ie. tabs.settings.index state), but I don't know how to implement them, and as a consequence don't whether it's feasible:

有一个返回按钮返回给调用视图( tabs.home 状态);或在当前的设置选项卡上单击,带给父视图,如果它是显示其子有一个

我怎样才能找回我的 tabs.settings.index 状态?谢谢,

How can I get back to my tabs.settings.index state? Thanks,

推荐答案

我工作围绕这一问题通过显示状态 tabs.settings.sub 的一个模式的看法。在这个答案。

I worked around this problem by showing the view of state tabs.settings.sub in a modal. More details in this answer.