处理国家作为新干线的离子与框架角UI的路由器 [英] Handle State as new Route in Ionic Framework with Angular UI-Router
问题描述
我使用的离子框架与AngularJS UI的路由器和$ stateProvider在我的应用程序处理不同的看法。
I'm using the Ionic Framework with its AngularJS UI-Router and $stateProvider to handle different views in my app.
不过,我无法找出如何告诉$ stateProvider,我得到了不同的主视图的,每一个具有不同子视图。
However, I'm having trouble figuring out how to tell the $stateProvider that I got different "Main View's", with each having different Subviews.
当我在 /#/家
例如,点击哪个把我送到 /#/链路上的
,那么 /#/约
没有得到呈现,因为它是自己的,新的看法。相反,它转换到它,因为它是 /#/家
。
When I'm on /#/home
for example, and click on a link which sends me to /#/about
, then /#/about
doesn't get rendered as it's own, new view. Instead it transitions to it as it were a subpage of /#/home
.
它的工作原理像它应该当我更换$ stateProvider与AngularJS $ routeProvider,但随后所有的转变都没有了。
It works like it should when I replace $stateProvider with the AngularJS $routeProvider, but then all the transitions are gone.
我创建了一个笔给你看看吧。
I've created a Pen for you to take a look at it.
的http://$c$cpen.io/anon/pen/gBDFi
应该有他们之间没有过渡。每一个基地的网址应该是一个新的标签。
There should be no transition between them. Every "base" url should be a new "tab".
推荐答案
不知道是不是因为它被张贴日这仍然是相关的,我决不是一个NG-PRO但这里是我尝试的 JSBinLink
don't know if this is still relevant as it was posted February and I'm by no means a ng-pro but here is my attempt JSBinLink
两个主要的事情,我在哪里包裹在离子的标签内容,并在stateProvider添加它作为一个抽象状态。
Two major things I did where to wrap the content in ion-tabs and add it in the stateProvider as an abstract state.
通过这个结构有两个独立的标签家,关于 - 通知,没有后退按钮。
但是,如果您导航到汤姆中关于 - 你得到一个返回按钮
With this construct you have two independent tabs "Home", "About" - notice, no back button. However if you navigate to "Tom" within "About" - you get a back button.
有其他的方式来实现类似的东西,一个是创建子状态和这样的。
There are other ways to achieve something similar, one is to create child states and such.
我会建议检查了UI的路由器文档。
这主要是写得很好,非常翔实 - 还有汤姆金德贝格的解释它的主要概念上的这里。
I would recommend to check out the UI-Routers documentation. It's mostly well written and very informative - there is also a create video of Tom Kindberg explaining the main concepts of it over here.
希望这有助于。
这篇关于处理国家作为新干线的离子与框架角UI的路由器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!