Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS Routing Case Sensitivity

I haven't been able to find a straightforward answer to this, which leads me to believe that it's something really really simple. Either way, here I go.

All of the calls in my $routeProvider work great, but are case sensitive. Here's a code sample:

config(function ($routeProvider) {     $routeProvider.         when('/', { controller: 'TmpCtrl', templateUrl: '/app/home.html' }).         when('/foo', { controller: 'TmpCtrl', templateUrl: '/app/foo.html' }).           otherwise({ redirectTo: '/' }); }); 

What do I need to add so that '/Foo', '/fOO', '/FoO', etc, all redirect to the same path?

like image 308
ThisLanham Avatar asked Jul 24 '13 03:07

ThisLanham


People also ask

Is AngularJS case sensitive?

The routes that are configured using UI-Router are case-sensitive by default.

Which of the following makes route path case sensitive in AngularJS Mcq?

Answer: A is the correct option. The lowercase filter converts a text to lower case text. That's why it is added to the AngularJS expression to filter out the result.


1 Answers

There is an option you can pass to $routeProvider to toggle case sensitivity:

config(function ($routeProvider) {     $routeProvider.         when('/', { controller: 'TmpCtrl', templateUrl: '/app/home.html' }).         when('/foo', { controller: 'TmpCtrl', templateUrl: '/app/foo.html', caseInsensitiveMatch: true }).           otherwise({ redirectTo: '/' }); }); 
like image 199
John Sparwasser Avatar answered Oct 04 '22 14:10

John Sparwasser