我有两个routes
路由到一个名为controller
的{{1}}。
一个使用$ routeParams而一个没有它。
storyboard
但是当我致电 $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'});
时,Angular会将我重定向到/storyboard/addSession
,并使用$ routeParams获取/storyboard/addSession
。
答案 0 :(得分: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'
});