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

Mik*_*ras 7 cross-browser internet-explorer-8 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>
Run Code Online (Sandbox Code Playgroud)

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

谢谢.

max*_*sam 12

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

 <!doctype html>
Run Code Online (Sandbox Code Playgroud)

原版的:

试试这个

<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>
Run Code Online (Sandbox Code Playgroud)

  • 得到它了.添加<!doctype html>让它停止默认为Quirks模式,这是我的大多数问题的原因,然后我只需修复一些随机错误,这些错误在好的浏览器中都没有问题.谢谢您的帮助. (5认同)