Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
387 views
Welcome To Ask or Share your Answers For Others

1 Answer

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: '/' });
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...