我正在开发一个使用 AngularJs 的大型应用程序。
当我在 IE8 中查看页面时,我收到 super 漂亮的控制台错误,例如 Object doesn't support property or method 'module'
, Object doesn't support property or method 'widget'
,无法获取属性“controller”的值:对象为 null 或未定义
,IE 真的很烂,你不能告诉他们下载 chrome 吗?
与它斗争了一段时间后,我决定记录 typeof angular
,控制台返回 undefined
。
在 IE9、IE10 和所有不差劲的浏览器中,一切都按预期工作。
请帮忙!
编辑:
看起来 angular 在到达我的第一个 Controller 之前是undefined
,所以我不认为它与 ieshim 有关系......
最佳答案
我已经使用 IE8 六个月了,感受一下你的痛苦。
没有看到你的代码,很难准确地说出哪里出了问题
这是我刚刚用 IE8 测试的一个非常非常基本的页面,供您比较:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta charset="utf-8">
<title>Prompt Detail View</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- disable browser cache -->
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<!--[if lte IE 8]>
<script>
document.createElement('ng-include');
document.createElement('ng-pluralize');
document.createElement('ng-view');
// Optionally these for CSS
document.createElement('ng:include');
document.createElement('ng:pluralize');
document.createElement('ng:view');
</script>
<![endif]-->
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/angular-1.0.2.js" ng:autobind></script>
<script>
var pageModule = angular.module('pageModule',[])
.controller('pageCtrl',function($scope) {
$scope.foo = 'my foo';
});
</script>
</head>
<body>
<div ng-app="pageModule"
ng-controller="pageCtrl">
{{foo}}
</div>
</body>
</html>
关于javascript - AngularJS 在 IE8 中未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15884699/