我正在基于AngularJS SPA Visual Studio模板(http://visualstudiogallery.msdn.microsoft.com/5af151b2-9ed2-4809-bfe8-27566bfe7d83)构建一个新的angularJS应用程序
这使用ui-router(https://github.com/angular-ui/ui- router)进行路由。
但是,它似乎区分大小写。
知道我将如何指示angular / ui-router忽略url参数的大小写吗?
url
在应用程序中区分大小写无关紧要,尽管用户应该在特定页面上输入网址以输入应用程序,但我们需要确保about与aBouT
about
aBouT
干杯
通过注释中指向原始问题的链接,我能够获得所需的答案。
在我的$stateProvider.state(......)路线之前,我 现在有这段代码:
$stateProvider.state(......)
$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); } // because we've returned nothing, no state change occurs });
本质上,它将toLowerCase()是一个还不是全部小写的URL。
toLowerCase()
完成后,它将替换url而不是重定向。然后以匹配状态进行。