javascript 抽象状态如何在 Ionic 中工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27524757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 07:35:06  来源:igfitidea点击:

How abstract states work in Ionic?

javascriptangularjscordovaionic-framework

提问by Ashok Kumar Sahoo

How abstract states work? What is the purpose of the abstract tabs? What is the purpose of the template included in abstract tab? Can I have more than one abstract states? Can I switch from one state to another which are in different abstract states?

抽象状态如何工作?抽象选项卡的目的是什么?包含在抽象选项卡中的模板的目的是什么?我可以有多个抽象状态吗?我可以从一种状态切换到处于不同抽象状态的另一种状态吗?

I modified the app.js to have 2 abstract states from the default tab template. https://gist.github.com/ashoksahoo/6bcad2c62e1abaa3de74

我将 app.js 修改为具有来自默认选项卡模板的 2 个抽象状态。 https://gist.github.com/ashoksahoo/6bcad2c62e1abaa3de74

But I cant get index.html#/friend/:id working, and FriendDetailCtrlis also not firing.

但我不能得到index.html#/friend/:id workingFriendDetailCtrl也没有开火。

采纳答案by Jesper We

Abstract states cannot be navigated to. Their purpose is to have several (non-abstract) states share a common parent, without having to define a parent state that can be navigated to.

无法导航到抽象状态。它们的目的是让多个(非抽象)状态共享一个公共父状态,而不必定义可以导航到的父状态。

This can be useful in many situations. See here: https://github.com/angular-ui/ui-router/wiki/Nested-States-%26-Nested-Views#abstract-states

这在许多情况下都很有用。请参阅此处:https: //github.com/angular-ui/ui-router/wiki/Nested-States-%26-Nested-Views#abstract-states

You can have many abstract states. You can use $state.go() to switch between any two states, even if they have different parents, abstract or not.

你可以有很多抽象状态。您可以使用 $state.go() 在任何两个状态之间切换,即使它们有不同的父级,无论抽象与否。

Your URL index.html#/friend/:idlooks strange. tab.triends has an argument. friend does not.

你的网址index.html#/friend/:id看起来很奇怪。tab.triends 有一个论点。朋友没有。

The proper URL for the friends state is: /#/tab/friends/1234

朋友状态的正确 URL 是: /#/tab/friends/1234

For the friend state (no argument!): /#/friend

对于朋友状态(没有参数!): /#/friend