【发布时间】:2015-04-25 23:57:26
【问题描述】:
我正在尝试使用 stateProvider 实现嵌套状态。使用 url-routing 加载嵌套状态时面临问题。我为其中一个独立状态创建了两个独立状态和 2 个嵌套状态。请检查以下状态配置:
.state('state1',{
url : "/page1",
templateUrl : "/views/page1.html",
contoller : 'page1ctrl'
})
.state('state2', {
url : "/page2",
templateUrl : "/views/page2.html",
controller : 'page2ctrl'
})
state('state2.nestedstate1', {
url : "/:nestedstate1", //passing as parameter
templateUrl : "/views/temp1.html",
controller : 'page2ctrl'
})
.state('state2.nestedstate1.nestedstate2', {
url : "/nestedstate2/:param1/:param2",
templateUrl : "/views/temp2.html",
controller : 'ctrl'
})
问题:如果我尝试使用完整 url index.html/page2/nestedstate1/nestedstate2/fname/lname 直接加载完整页面,它将首先从最后一个子状态 nestedstate2 加载数据,然后回退到其父状态 'nestedstate1 ' 并将 url 更新为index.html/page2/nestedstate1。
必需的行为是先执行父状态,然后是子状态。例如,nestedstate1 必须在 nestedstate2 之前加载。
如果我缺少任何配置,请提出建议。
谢谢
【问题讨论】:
-
绝对需要为此制作一个 plnkr 或小提琴。 UI Router 相当复杂。
-
我很快就会发布一个 plnkr。正在努力。
-
同时,如果有人面临同样的问题。请发表评论。
标签: angularjs angular-ui-router angularjs-routing angular-ui-router-extras