2014-10-10 65 views
1

到URL我试图理解为什么角不断增加?%3F到URL时,我有可选参数的URLAngularjs routeProvider增加*?*或%3F可选参数

$routeProvider 
 
.when('/:locale?/', { 
 
    templateUrl: '/views/index.html', 
 
    controller: 'myController', 
 
    title: 'Title' 
 
}) 
 
.otherwise({ 
 
    redirectTo: '/' 
 
}); 
 
// html5mode 
 
$locationProvider.html5Mode(true); 
 
$locationProvider.hashPrefix('!');

的URL将结束与http://myexampledomain.com/en-US%3F/

我不知道,以帮助及彼的正确答案是什么其他的信息,我应该提供,但PLE这个让我知道。

回答

1

$routeProviderrouting不适用于查询字符串,我认为角度认为您正在尝试使用它们而不是定义可选参数。

我不认为你是正确定义您的路线您的选购PARAMS我相信,你需要做的是这样的:

$routeProvider 
    .when('/:locale?', { 
    templateUrl: '/views/index.html', 
    controller: 'myController', 
    title: 'Title' 
}) 
.otherwise({ 
    redirectTo: '/' 
}); 

注意,我是你的路线后取出/,现在我觉得角应该能够通过可选参数识别此路线。