一、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); } }); });
这样处理,浏览器的地址栏总会显示小写,但是这是除了动态参数之外的部分。
相关文章:
https://github.com/angular-ui/ui-router/wiki/URL-Routing
AngularJS 动态加载控制器实例-ocLoazLazy(二)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。