【发布时间】:2017-06-02 17:27:44
【问题描述】:
我在配置路由器时遇到问题。
去/:lang/:country & /:lang/:country/:city 的路由器不工作。前三条路线正常,我该如何解决?
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider
.when('/', { // works
templateUrl : 'templates/main.html',
controller: 'MainCtrl'
}).when('/:lang', { // works
templateUrl : 'templates/main.html',
controller: 'MainCtrl'
}).when('/:lang/premium-benefits', { // works
templateUrl : 'templates/premium_benefits.html',
controller: 'PremiumBenefitsCtrl'
}).when('/:lang/:country', { // NOT working
templateURL : 'templates/destination.html',
controller: 'DestinationCtrl'
}).when('/:lang/:country/:city', { // NOT working
templateURL : 'templates/destination.html',
controller: 'DestinationCtrl'
}).otherwise({
templateURL : 'main.html'
});
$locationProvider.html5Mode({enabled: true, requireBase: true});
}]);
【问题讨论】:
-
你能定义“不工作”是什么意思吗?你有什么错误吗?
-
抱歉,只是属性名称 templateURL 的拼写错误,所以它不起作用
标签: angularjs ngroute angularjs-1.6