AngularJS 路由区分大小写 [英] AngularJS Routing Case Sensitivity

查看:34
本文介绍了AngularJS 路由区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直无法找到一个直截了当的答案,这让我相信这真的很简单.不管怎样,我走了.

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.

我的 $routeProvider 中的所有调用都运行良好,但区分大小写.这是一个代码示例:

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

我需要添加什么才能使/Foo"、/fOO"、/FoO"等都重定向到同一路径?

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

推荐答案

有一个选项可以传递给 $routeProvider 来切换大小写敏感度:

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

这篇关于AngularJS 路由区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆