离子NAV-后退按钮和state.go - 背动作ambigously工作 [英] ion-nav-back-button and state.go - back action working ambigously

查看:178
本文介绍了离子NAV-后退按钮和state.go - 背动作ambigously工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与AngularJS(stateProvider)

一起使用离子

我加入以下为抽象状态默认模板code

 <离子导航栏类=扎稳>
 <离子NAV-后退按钮>
 < /离子NAV-后退按钮>
< /离子导航栏>

在默认的控制器被加载(显示StateA),它通过调用转换到另一种状态(StateB)

  $ state.go(...);

这将导致加载另一个模板,它就会显示在子视图。此外,它也可以激活后退按钮。


  1. 点击导航栏中的后退按钮后,需要返回到默认页面(StateA)。

  2. 在导航栏的后退按钮变为不可见,但如果我preSS后退按钮上移动,它把我带回到了过渡状态(StateB)。

这是有点不可思议,因为为什么StateB再次得到显示,而不是应用越来越封闭。


解决方案

  

当用户浏览整个应用,离子能够跟踪其导航的历史。通过了解他们的历史,正确的意见进入和退出使用平台的过渡风格转换之间


  
  

离子文件


离子会自动跟踪你的国家的历史,你使用stateProvider的,所以它就像历史的堆栈。

您从状态A开始,堆栈只有一个页面:A

  | A |

在你去到状态B,这将是推入历史堆栈:

  | C |
| A |

和由离子提供的导航视图显示在导航栏后退按钮,因为它认为你正在做的状态过渡,并帮你保持历史为你(就像在iOS上的导航控制器)。

然后,如果你点击导航栏的后退按钮,历史堆栈再次蹦出B,并显示给你的。

  | A |

后退按钮会为你删除,因为你回到初始状态(像根页)。


  

为什么点击后退按钮上移动,它需要我回
  过渡状态呢?


您的操作全局窗口对象的窗口史(编译离子的应用仍在考虑一个web应用程序,即使是在移动平台,我认为)。这是pretty就像你做什么,当你在浏览器中点击后退按钮。

  / A<  -  / B(窗口史)LT;  -  / A(当前页)


  1. 如果你想要做的事与ionicHistory,检查<一href=\"http://forum.ionicframework.com/t/is-there-a-way-to-clear-out-the-nav-router-history-and-$p$pvent-a-back-button/356/6\"相对=nofollow>这个讨论


  2. 如果你想要做的事与你的设备按钮的行为,检查的此相关的话题


我也学习了这里的离子,所以不知道是我得到的所有概念正确与否。希望这有助于!

I am using Ionic along with AngularJS (stateProvider)

I have added following code in a default template for abstract state

<ion-nav-bar class="bar-stable">
 <ion-nav-back-button>
 </ion-nav-back-button>
</ion-nav-bar>

When the default controller is loaded (Displays StateA), it transitions to another state (StateB) by invoking

$state.go(...);

This results in loading another template and it gets displayed in child view. Additionally, it also activates back button.

  1. After clicking the back button in nav bar, it takes back to the default page (StateA).
  2. The back button in navbar becomes invisible, but if I press back button on mobile, it takes me back to the transitioned state (StateB).

This is bit weird, as why the StateB is again getting displayed instead of application getting closed.

解决方案

As a user navigates throughout your app, Ionic is able to keep track of their navigation history. By knowing their history, transitions between views correctly enter and exit using the platform's transition style.

From Ionic Doc

Ionic will automatically keep track of your state history for you using stateProvider, so it is like a stack of history.

You start from state A, the stack has only one page: A.

| A |

After that you go to state B, it will be push into the history stack:

| B |
| A |

And the nav-view provided by Ionic will show a back button in the nav-bar because it thought you are doing a state transition and helped you to keep the history for you (like the navigation controller in iOS).

Then if you click the back button in nav-bar, the history stack pop out the B, and display A for you again.

| A |

The back button will be removed for you because you go back to the initial state(like a root page).

why click back button on mobile, it takes me back to the transitioned state?

You are manipulate the window history of the global window object(Compiled Ionic App is still consider a web app, even in mobile platform I think). This is pretty much like what you do when you hit the Back button in your browser.

/A <- /B(window history) <- /A (current page)

  1. If you want to do something with ionicHistory, check this discussion

  2. If you want to do something with your device button behavior, check this related topics

I am also learning the Ionic here, so not sure am I get all concepts correct or not. Hope this helps!

这篇关于离子NAV-后退按钮和state.go - 背动作ambigously工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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