在Internet Explorer 7上运行的应用程序AngularJS [英] Running AngularJS App on Internet Explorer 7

查看:159
本文介绍了在Internet Explorer 7上运行的应用程序AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是为了确保如果AngularJS工作在我需要的浏览器,我做了一个简单的数据暴饮暴食演示,关于火狐,Chrome的IE8 +工作正常,但我还需要它IE7工作。可惜的是,我不能让它进行这项工作。这只能说明,上面有花括号的HTML,忽略纳克 - 属性

Just to make sure if AngularJS works on the browsers I need, I made a simple data-binging demo that works fine on Firefox, Chrome an IE8+ but I also need to make it work on IE7. Unfortunatelly I can't make it work on it. It only shows the html with the curly braces on it, ignoring ng- attributes.

我已经检查几个帖子 <一个href=\"http://stackoverflow.com/questions/11984223/angularjs-data-binding-issue-on-internet-explorer-using-curly-braces\">about AngularJS 在Internet Explorer上,并试图对每一个建议的修复,但没有任何工程上我的演示。

I have checked several posts about AngularJS on Internet Explorer and tried the suggested fixes on each one but nothing works on my demo.

这是我的演示的HTML:

This is the HTML of my demo:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Angular IE7 Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<!--[if lt IE 9]>
<script type="text/javascript" src="angularjs/html5shiv.js"></script>
<![endif]-->
<!--[if lt IE 8]>
<script type="text/javascript" src="angularjs/json3.js"></script>
<![endif]-->
<script language="JavaScript" src="angularjs/angular.min.js"></script>
<script language="JavaScript" src="angularjs/test.js"></script>
</head>
<body class="ng-app">
    <div ng-controller="serversCtrl">
        <p>{{texto}}</p>

        <table border="1">
            <tbody>
                <tr><th>Col1</th><th>Col2</th><th>Col3</th></tr>
                <tr ng-repeat="item in items"><td>{{item.col1}}</td><td>{{item.col2}}</td><td>{{item.col3}}</td></tr>
            </tbody>
        </table>
    </div>
</body>
</html>

这是JavaScript的包含控制器test.js和模型:

And this is the test.js javascript containing the controller and the models:

function serversCtrl($scope, $http, $location) {
    $scope.texto = "Texto dinamico";
    $scope.items = [
        {col1: "foo1", col2: "bar1", col3: "baz1"},
        {col1: "foo2", col2: "bar2", col3: "baz2"},
        {col1: "foo3", col2: "bar3", col3: "baz3"},
        {col1: "foo4", col2: "bar4", col3: "baz4"},
        {col1: "foo5", col2: "bar5", col3: "baz5"}
    ];
}

我是不是做错了什么?是否有任何其他提示,使其工作,我错过了什么?

Am I doing something wrong? Is there any other tip to make it work that I have missed?

编辑:我使用AngularJS V1.0.5

I'm using AngularJS v1.0.5

推荐答案

一些阅读后,我可以使它正常工作。

After some more reading I could make it work.

与IE7的问题是引导。这不是任何射击!所以我做了一个手动初始化如图本页面和它的工作。

The problem with IE7 was the bootstrapping. It was not firing any! so I made a manual initialization as shown in this page and it worked.

这是code我加入HTML确保在Internet Explorer 8或更低(因为如果我火了所有浏览器的一些事件处理的非IE浏览器发射两次),这只会火:

This is the code I added to the HTML assuring it will only fire on Internet Explorer 8 or lower (because if I fire it for all browsers some event handlers fire twice for non-ie browsers):

<!--[if lte IE 8]>
<script type="text/javascript">
    $(document).ready(function() {
        angular.bootstrap(document);
    });
</script>
<![endif]-->

$的document.ready()部分是jQuery的办法,以确保当身体一切都已经加载此code将被执行,但因为我用在我的网站我把它的优势jQuery的。

The $document.ready() part is the jQuery way to be sure this code will be executed when everything on the body has been loaded but since I was using jQuery on my site I took advantage of it.

这篇关于在Internet Explorer 7上运行的应用程序AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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