0

我有两个routes路由到一个controllerstoryboard.

一个有 $routeParams,一个没有。

     $routeProvider.when('/storyboard/:cureId',
    {
        templateUrl:    '/partials/storyboard.html',
        controller: 'Storyboard',
        access: access.parent,
        area:     'storyboard'
    });    

$routeProvider.when('/storyboard/addTarget',
    {
        templateUrl:'/partials/storyboard_new_target.html',
        controller: 'Storyboard',
        access: access.supervisor,
        area:     'storyboard'
    });   

$routeProvider.when('/storyboard/addSession',
    {
        templateUrl:'/partials/storyboard_new_session.html',
        controller: 'Storyboard',
        access: access.parent,
        area:     'storyboard'
    });     


$routeProvider.otherwise({redirectTo:'/404'});

但是当我打电话给/storyboard/addSessionAngular 时,我总是将我重定向到/storyboard/addSession,并addSession使用 $routeParams。

4

1 回答 1

3

ngRoute根据注册顺序处理路由。所以/storyboard/addSession应该匹配第一条路线(即/storyboard/:cureId)。我想您希望它与示例中的第三条路线相匹配。只需更新顺序,以便最后注册参数化路由。

$routeProvider.when('/storyboard/addTarget',
{
    templateUrl:'/partials/storyboard_new_target.html',
    controller: 'Storyboard',
    access: access.supervisor,
    area:     'storyboard'
});   
$routeProvider.when('/storyboard/addSession',
{
    templateUrl:'/partials/storyboard_new_session.html',
    controller: 'Storyboard',
    access: access.parent,
    area:     'storyboard'
});     
$routeProvider.when('/storyboard/:cureId',
{
    templateUrl:    '/partials/storyboard.html',
    controller: 'Storyboard',
    access: access.parent,
    area:     'storyboard'
});  
于 2013-10-03T16:27:30.887 回答