博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AngularJS路由之ui-router(三)大小写处理
阅读量:4287 次
发布时间:2019-05-27

本文共 889 字,大约阅读时间需要 2 分钟。

一、ui-router 路由地址处理大小写

默认ui-router的state()方法指定路由配置对大小写敏感。

解决方案一:$urlRouterProvider服务的rule()  方法提供处理客户端连接的接口,

app.config(function ($urlRouterProvider) {    // Here's an example of how you might allow case insensitive urls    // Note that this is an example, and you may also use     // $urlMatcherFactory.caseInsensitive(true); for a similar result.    $urlRouterProvider.rule(function ($injector, $location) {        //what this function returns will be set as the $location.url        var path = $location.path(), normalized = path.toLowerCase();        if (path != normalized) {            //instead of returning a new url string, I'll just change the $location.path directly so I don't have to worry about constructing a new url string and so a new state change is not triggered            $location.replace().path(normalized);        }    });});
这样处理,浏览器的地址栏总会显示小写,但是这是除了动态参数之外的部分。

相关文章:

转载地址:http://inogi.baihongyu.com/

你可能感兴趣的文章
一段比较坑的求职经历-from android little guy.
查看>>
Weex学习 and Kotlin学习
查看>>
几种直播流媒体协议
查看>>
ExoPlayer
查看>>
流媒体框架
查看>>
java语言当中-sleep()和await()的差异
查看>>
java锁机制
查看>>
android热插件,热更新,热修复,模块化
查看>>
(AndroidStudio)gradle配置多个代码仓库repositories
查看>>
facebook登录和分享
查看>>
YouTube集成
查看>>
程序员之路--项目重构的开发者心态
查看>>
Android 8.0新特性
查看>>
Android7.0新特性
查看>>
Android6.0新特性
查看>>
Andriod5.0新特性
查看>>
Android4.4新特性
查看>>
android的recovery,fastboot和bootloader
查看>>
android动画加速器(插值器)interpolator和速度曲线
查看>>
task ':app:prepareDebugAndroidTestDependencies'+'multidex1.0.2'
查看>>