javascript - AngularJS 在 IE8 中未定义

标签 javascript internet-explorer internet-explorer-8 angularjs

我正在开发一个使用 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/

相关文章:

html - IE中的表单按钮问题

css - 如何增加 GWT celltable : Issue with IE? 的单元格高度

css - IE中的中心网站

IE 8 问题中的 Javascript 数组

javascript - 文档模式 IE8 中的奇怪行为 Highcharts 饼图

javascript - mocha测试中以下js箭头函数中 `this`指向什么?

javascript - Jquery触发类更改

javascript - 谷歌地图 JavaScript API

javascript - Mongoose 模型对象行为异常

css - IE 在图像 AlphaImageLoader 和 alpha(opacity=60) 上应用 2 个过滤器