Angular UI-Router无法使用Internet Explorer 9解析 [英] Angular UI-Router Not Resolving with Internet Explorer 9
问题描述
我有一个Angular v1.3应用程序,该应用程序使用Angular ui-router v0.2.13进行所有路由.该网站在所有浏览器(包括IE 10和IE 11)上都可以正常运行,但不适用于IE 9(我们决定不采用IE8,我知道v1.3仍然不支持该版本).尽管已尽了最大努力,但IE 9仍会继续解析为我的$stateProvider's
otherwise
路由(该路由设置为/*path
,这可能是罪魁祸首,因此出于测试目的,我禁用了该路由).
I have an Angular v1.3 application, which uses Angular ui-router v0.2.13 for all routing. The site works great on all browsers, including IE 10 and IE 11, but not IE 9 (we've decided not to pursue IE8, which I understand isn't supported by v1.3, anyway). Despite my best efforts, IE 9 continually resolves to my $stateProvider's
otherwise
route (which is set to /*path
, a possible culprit, so I disabled that route for testing purposes).
为了尝试解决其他问题,我尝试设置$locationProvider.html5Mode(false)
,修改了$locationProvider.hashPrefix
,将<base href="/" />
更改为各种URL,包括<base href="/#!"/>
,我什至在<html>
标记中都加入了xmlns:ng="http://angularjs.org"
来很好地衡量.不管我尝试什么,IE 9都会不断尝试解析为我的otherwise
路由,如果该路由被禁用,则什么也不做.顺便说一句,我的主页路由URL设置为/
.
In an attempt to get any other route to resolve, I've tried setting $locationProvider.html5Mode(false)
, modified the $locationProvider.hashPrefix
, changed the <base href="/" />
to various URLs, including <base href="/#!"/>
, and I've even included xmlns:ng="http://angularjs.org"
in the <html>
tag for good measure. No matter what I try, IE 9 continually tries to resolve to my otherwise
route, or nothing if that route is disabled. BTW, my home page route URL is set to /
.
我一直在关注代码的发布截止日期,所以我将是第一个承认我有可能忽略明显事情的人.谁能提供任何其他提示或技巧来使ui路由器在IE 9中正确解析?
I've been up to my eyeballs in code with a launch deadline looming, so I'll be the first to admit that I'm potentially overlooking something obvious. Can anyone offer any other tips or tricks to cause ui-router to resolve properly in IE 9?
推荐答案
对我来说,IE9可以正确路由哈希网址/#/example
,但是访问/
则可以解析为其他路由.我通过使用其他函数来解决此问题,并检查其中的网址.
For me, IE9 routes correctly for hash urls, /#/example
, but visiting /
would resolve to the otherwise route. I worked around this by using a function for otherwise, and checking the url in it.
$urlRouterProvider.otherwise(function($injector){
var state = $injector.get('$state');
var location = $injector.get('$location');
if (!location.url()) {
// handle HTML5 fallback / IE9 when url has no hash
return state.go('home');
}
state.go('404');
});
这篇关于Angular UI-Router无法使用Internet Explorer 9解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!