AngularJS 路由在 IE7 中不起作用 [英] AngularJS Routing not working in IE7

查看:27
本文介绍了AngularJS 路由在 IE7 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have been implementing Routing in my app following the tutorial

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

我的版本无法在 IE7 中运行,在花了一段时间试图找出我遗漏/做错了什么之后,我发现该示例不起作用.

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.

http://angular.github.com/angular-phonecat/步骤 7/app/

有人知道如何让它工作吗?

Anyone know how to get this to work?

推荐答案

好吧,我遇到了同样的问题,所以我开始了悬赏,但在那之后我找到了可行的解决方案(至少对我而言):

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

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

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

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

(其中 myapp 实际上是您的应用名称)

(where myapp is really your app name)

总结一下,这是我的 IE7/8/9 工作 HTML 页面:

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

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

这篇关于AngularJS 路由在 IE7 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆