角UI路由器:1网址触发两个父母和孩子的状态 [英] Angular ui-router: 1 url trigger both parent and child state
本文介绍了角UI路由器:1网址触发两个父母和孩子的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我去到网址 /博客/职位/编辑
,2 XHR请求触发,你可以在图像中看到下文。
When I go to the url /blog/post/edit
, 2 xhr requests trigger, as you can see in the image below.
这是我如何定义路线:
$stateProvider
.state('blog', {
url: '/blog',
templateUrl: '/blog'
})
.state('blog.post', {
url: '/post',
template: '<ui-view></ui-view>',
abstract: true
})
.state('blog.post.edit', {
url: '/edit',
templateUrl: '/blog/post/edit'
});
谁能帮我搞清楚为什么发生这种情况?
Can anyone help me figuring out why this is happening?
推荐答案
的的意见的作为迅速讨论,性质的 UI路由器
是的工作这种方式。为了展示嵌套的状态与父母的状态
As quickly discussed in comments, the nature of the ui-router
is to work this way. To show nested states with their parent states
最好的办法如何看待它就像一个的崩溃的 TreeView控件
:
The best way how to think about it is like a collapsed TreeView
:
- 如果我们希望看到叶的(或任何不根节点)的我们必须要看到/加载其父母,祖父母......和根也是如此。
- 但一旦我们希望看到一个兄弟姐妹,我们不必重新加载所有的家长对根的结构......是已经在玩
- if we want to see a leaf (or any not root node) we have to see/load its parent, grand-parent ... and the root as well.
- but once we want to see a sibling, we do not have to reload all the parent-to-root structure... is is already in play
这就是如何使用 UI路由器
是基本的设计。
And that's how the ui-router
was basically designed.
这篇关于角UI路由器:1网址触发两个父母和孩子的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文