$urlRouterProvider
.when('/EcoCOOL', '/ecocool')
.when('/ECOCOOL', '/ecocool')
.when('/EcoCool', '/ecocool')
.when('/EcoCOOL/USA', '/ecocool/USA')
.when('/ECOCOOL/USA', '/ecocool/USA')
.when('/EcoCool/USA', '/ecocool/USA')
.when('/EcoCOOL/Europe', '/ecocool/Europe')
.when('/ECOCOOL/Europe', '/ecocool/Europe')
.when('/EcoCool/Europe', '/ecocool/Europe')
.when('/EcoCOOL/Asia', '/ecocool/Asia')
.when('/ECOCOOL/Asia', '/ecocool/Asia')
.when('/EcoCool/Asia', '/ecocool/Asia')
.when('/EcoCOOL/UAE', '/ecocool/UAE')
.when('/ECOCOOL/UAE', '/ecocool/UAE')
.when('/EcoCool/UAE', '/ecocool/UAE')
.when('/EcoCOOL/Canada', '/ecocool/Canada')
.when('/ECOCOOL/Canada', '/ecocool/Canada')
.when('/EcoCool/Canada', '/ecocool/Canada')
有没有办法先检查EcoCOOL?使所有这些都小写。那么我只需为这些国家运行1条规则。即/ ecocool / MyCountry。而不是检查3个不同的单词拼写然后检查国家?
ie ..有更短的方法吗?比如使用*或/ * / etc?
答案 0 :(得分:4)
您可以设置rule()
- 自定义网址处理:
app.config(function($urlRouterProvider){
// Here's an example of how you might allow case insensitive urls
$urlRouterProvider.rule(function ($injector, $location) {
var path = $location.path(), normalized = path.toLowerCase();
if (path != normalized) return normalized;
});
})