javascript AngularJS 路由在 IE7 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12709745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 16:56:23  来源:igfitidea点击:

AngularJS Routing not working in IE7

javascriptinternet-explorer-7angularjs

提问by Tom

I have been implementing Routing in my app following the tutorial

我一直在按照教程在我的应用程序中实现路由

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?

有谁知道如何让这个工作?

回答by adrien

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
  • Use JSON2.js
  • Add all these attributes to your html node:

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

  • 使用 HTML5 垫片
  • 使用 JSON2.js
  • 将所有这些属性添加到您的 html 节点:

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

(where myappis 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>