要求:
/month Redirect to /month/1 (january is the default month)
/month/ Redirect to /month/1
/month/4 No redirect, show april
我最好的尝试:
$routeProvider
.when('/month/:monthNo', {
templateUrl: 'views/month.html',
controller: 'MonthCtrl'
})
这有效:
.when('/month', {
redirectTo: '/month/1' // default redirect to january
})
这不会(注意试用斜线:/month/):
.when('/month/', {
redirectTo: '/month/1'
})
/month/
比赛.when('/month/:monthNo'...
是这样的:
.when('/month/:monthNo', {
runThisCodeFirst: function() { if(!monthNo) redirectTo: '/month/1'}
templateUrl: 'views/month.html',
controller: 'MonthCtrl'
})
或者这个问题还有其他解决方案吗?