Reputation: 10453
I'm trying to understand why Angular keep adding ?
or %3F
to the URL when I have optional parameter in the URL
$routeProvider
.when('/:locale?/', {
templateUrl: '/views/index.html',
controller: 'myController',
title: 'Title'
})
.otherwise({
redirectTo: '/'
});
// html5mode
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
The URL will end up with http://myexampledomain.com/en-US%3F/
I'm not sure what other information that I should provide to help getting the right answer here, but please do let me know.
Upvotes: 1
Views: 762
Reputation: 1390
$routeProvider
and routing
does not work with query strings, and I think that angular thinks that you are trying to use them rather then defining optional params.
I do not think you are defining your optional params correctly in your route I belive that you need to do it this way:
$routeProvider
.when('/:locale?', {
templateUrl: '/views/index.html',
controller: 'myController',
title: 'Title'
})
.otherwise({
redirectTo: '/'
});
Notice that I Removed the /
after your route and now i think angular should be able to recognize this route with optional params.
Upvotes: 1