通过注释中指向原始问题的链接,我能够获得所需的答案。
在我的
$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。
完成后,它将替换url而不是重定向。然后以匹配状态进行。



