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

查看:207
本文介绍了AngularJS Routing在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/step-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 shim

  • 使用JSON2.js

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

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

class =ng-app:myappid =ng-appng-app =myappxmlns:ng =ht tp://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 Routing在IE7中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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