14

Im trying to get my nested route working but it's giving me hard time for two days now :(

one level works fine

two levels works fine

three levels is not working!

can anybody please help me out?

Thanks in advance

angular.module('settings', []).config(['$stateProvider', '$routeProvider', '$urlRouterProvider', function($stateProvider, $routeProvider, $urlRouterProvider) {
    $stateProvider
        .state('settings', {
            url: '/settings',
           template:"Settings",
            controller: function(){
                console.log('settings');
            }
        }).
        state('settings.branch', {
            url: '/{branchId:[0-9]{1,8}}',
            template:"Branch",
            controller: function(){
                console.log('branch');
            }
        }).
        state('settings.branch.prop', {
            url: '/prop',
            template:"Property",
            controller: function(){
                console.log('property');
            }
        });
}]);

'/settings' is working

'/settings/1234' is working

'/settings/1234/prop' is not working, always return the prevues state 'Branch'

4

4 回答 4

13

I guess you didn't declare an ui-view in the Branch template

于 2013-05-29T20:02:45.957 回答
1

我遇到过同样的问题。对于settings.branch.prop,尝试设置url为:

url: '/{branchId:[0-9]{1,8}}/prop'
于 2013-07-18T13:05:54.767 回答
0

我们遇到了类似的问题。刚刚找到一个解决方案(不是很漂亮的想法)

所以我们有

/b2c/applicationShow --> applicationShowController (b2c.applicationShow) with an /:id 

/b2c/applicationShow/9238490392084/details --> detailsController (b2c.applicationShow.details) 

/b2c/applicationShow/9238490392084/details/someApp --> someAppController (b2c.applicationShow.details.someApp) 

/b2c/applicationShow/9238490392084/details/someApp/someTab --> this has no controller, only declare the previous one as parent. 

那么我们如何从 /b2c/applicationShow 转发到 /b2c/applicationShow/9238490392084/details/someApp/someTab (有一个列出所有应用程序的表格,然后单击一个链接假设将您带到那个特定的选项卡)

我们一一转发。

$state.go(b2c.applicationShow , {id: 9238490392084})

然后在 detailsController

$state.go(b2c.applicationShow.details.someApp); 

然后在 someAppController

$stage.go(b2c.applicationShow.details.someApp, {tab: someTab});

基本上状态机将采用最后一条路径,追加然后继续。好吧,就像我说的那样,它并不漂亮,但完成了工作。希望能帮助到你。

于 2014-10-21T14:34:38.000 回答
0

尝试用属性 ui-view 围绕分支视图内容包装一个 div,如下所示,

 <div ui-view> 
     branch content goes here .....
     ......

 </div>

为我做了伎俩!

于 2016-12-03T15:43:34.187 回答