AngularJS Routing在IE7中不起作用

时间:2021-09-15 19:41:34

I have been implementing Routing in my app following the tutorial

我在本教程后面的应用程序中实现了Routing

http://docs.angularjs.org/tutorial/step_07

http://docs.angularjs.org/tutorial/step_07

I couldn't get my version to work in IE7, and after spending a while trying to work out what I have missed / done wrong I have noticed that the example doesn't work.

我无法让我的版本在IE7中工作,并且花了一段时间试图弄清楚我错过了什么/做错了我注意到这个例子不起作用。

http://angular.github.com/angular-phonecat/step-7/app/

http://angular.github.com/angular-phonecat/step-7/app/

Anyone know how to get this to work?

任何人都知道如何让这个工作?

1 个解决方案

#1


54  

OK I had the same problem so I started the bounty, but after that I found the working solution (for me at least):

好吧我有同样的问题所以我开始了赏金,但之后我找到了工作的解决方案(至少对我而言):

  • Use HTML5 shim
  • 使用HTML5垫片
  • Use JSON2.js
  • 使用JSON2.js
  • Add all these attributes to your html node:

    将所有这些属性添加到您的html节点:

    class="ng-app:myapp" id="ng-app" ng-app="myapp" xmlns:ng="http://angularjs.org"

    class =“ng-app:myapp”id =“ng-app”ng-app =“myapp”xmlns:ng =“http://angularjs.org”

(where myapp is really your app name)

(其中myapp真的是你的应用名称)

So to recap, here is my IE7/8/9 working HTML page:

所以回顾一下,这是我的IE7 / 8/9工作HTML页面:

<!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="js/json2.js"></script>
    <![endif]-->
  </head>
  <body>
    <div ng-view></div>
  </body>
</html>

#1


54  

OK I had the same problem so I started the bounty, but after that I found the working solution (for me at least):

好吧我有同样的问题所以我开始了赏金,但之后我找到了工作的解决方案(至少对我而言):

  • Use HTML5 shim
  • 使用HTML5垫片
  • Use JSON2.js
  • 使用JSON2.js
  • Add all these attributes to your html node:

    将所有这些属性添加到您的html节点:

    class="ng-app:myapp" id="ng-app" ng-app="myapp" xmlns:ng="http://angularjs.org"

    class =“ng-app:myapp”id =“ng-app”ng-app =“myapp”xmlns:ng =“http://angularjs.org”

(where myapp is really your app name)

(其中myapp真的是你的应用名称)

So to recap, here is my IE7/8/9 working HTML page:

所以回顾一下,这是我的IE7 / 8/9工作HTML页面:

<!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="js/json2.js"></script>
    <![endif]-->
  </head>
  <body>
    <div ng-view></div>
  </body>
</html>