Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

internet explorer 8 - Why does ng-class="ng-app" break AngularJS?

To get AngularJS to work in IE7 and IE8, I add id="ng-app" and class="ng-app" to my ng-app element:

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

This has always worked in the past, but now I've added class="ng-app" to two different projects, and in both the view no longer renders in any browser. Has the way to do IE7/8 compatibility changed? I'm using version 1.0.2 from the CDN.

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Edit note: Add doctype tag will reduce some issues. Thanks @Mike Pateras

 <!doctype html>

Original:

try this

<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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...