为什么ng-class =“ng-app”会破坏AngularJS?

时间:2012-11-01 19:22:36

标签: internet-explorer-8 cross-browser internet-explorer-7 angularjs

要让AngularJS在IE7和IE8中运行,我将id =“ng-app”和class =“ng-app”添加到我的ng-app元素中:

<html id="ng-app" class="ng-app" ng-app="myApp">
   <div ng-view></div>
</html>

这在过去一直有效,但现在我已经将class =“ng-app”添加到两个不同的项目中,并且在两个视图中都不再在任何浏览器中呈现。有没有改变IE7 / 8兼容性的方法?我正在使用CDN的1.0.2版本。

谢谢。

1 个答案:

答案 0 :(得分:12)

编辑注释:添加doctype标记会减少一些问题。 谢谢@Mike Pateras

 <!doctype html>

原件:

试试这个

<html lang="en" class="ng-app:myapp" id="ng-app" ng-app="myapp" xmlns:ng="http://angularjs.org">
     <head>    
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <!--[if lte IE 8]>
          <script>
            document.createElement('ng-include');
            document.createElement('ng-pluralize');
            document.createElement('ng-view');
            document.createElement('ng:include');
            document.createElement('ng:pluralize');
            document.createElement('ng:view');
          </script>
        <![endif]-->
        <!--[if lt IE 8]>
          <script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20150503/json2.min.js"></script>
        <![endif]-->
      </head>