Reputation: 1171
How can I make routing in angular case insensitive? For example if I have a route for www.example.com/home which looks like this:
$routeProvider
.when('/home', {
templateUrl: 'pages/home/home-page.tmpl.html',
controller: 'HomeCtrl',
controllerAs: 'home'
});
How can I also set it up so that it would work with.
www.example.com/Home | www.example.com/HOME | www.example.com/HoMe etc?
Upvotes: 5
Views: 6100
Reputation: 164733
Seems you can simply set this property to make all route matching case insensitive
$routeProvider.caseInsensitiveMatch = true;
See https://docs.angularjs.org/api/ngRoute/provider/$routeProvider#caseInsensitiveMatch
Upvotes: 9
Reputation: 8971
There is an option for case insensitivity:
$routeProvider
.when('/home', {
templateUrl: 'pages/home/home-page.tmpl.html',
controller: 'HomeCtrl',
controllerAs: 'home',
caseInsensitiveMatch: true
});
Upvotes: 5