我也一直在努力與IE7和IE6兼容,並發現使用angularjs版本1.1.5而不是1.2.25可以防止你描述的錯誤。
除了這個簡單的例子,角度是否可用於IE6和IE7是另一回事。
以下代碼已在兼容模式設置爲ON的域上的IE6,7,8,9,11中進行了測試。
我認爲這個例子的很多部分都可以省略。我剛剛開始與角度,所以不能保證使用最佳做法。它至少應該提供一個起點。
<!DOCTYPE html>
<html class="ng-app:phonecatApp" ng-app="phonecatApp" id="ng-app" xmlns:ng="http://angularjs.org" lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE; IE=9; IE=8; IE=7" />
<meta charset="utf-8">
<title>My HTML File</title>
<link rel="stylesheet" href="../stylesheets/html5.css">
<!--[if lte IE 7]>
<script src="../Includes/Client/JS/json2.js"></script>
<![endif]-->
<!--[if lte IE 9]>
<script type="text/javascript" src="es5-shim-4.0.3-min.js"></script>
<![endif]-->
<script type="text/javascript" src="html5shiv.min.js"></script>
<script type="text/javascript" src="angular-1.1.x.js"></script>
<script type="text/javascript">
var phonecatApp = angular.module('phonecatApp', []);
phonecatApp.controller('PhoneListCtrl', function ($scope) {
$scope.phones = [
{'name': 'Nexus S',
'snippet': 'Fast just got faster with Nexus S.'},
{'name': 'Motorola XOOM™ with Wi-Fi',
'snippet': 'The Next, Next Generation tablet.'},
{'name': 'MOTOROLA XOOM™',
'snippet': 'The Next, Next Generation tablet.'}
];
});
</script>
</head>
<body ng-controller="PhoneListCtrl">
<ul>
<li ng-repeat="phone in phones">
{{phone.name}}
<p>{{phone.snippet}}</p>
</li>
</ul>
</body>
見接受答案:(http://stackoverflow.com/questions/15914675/running-angularjs-app-on-internet [**上的Internet Explorer 7 **運行AngularJS應用] -explorer-7) - 它提到了bootstrapping,儘管一般情況下,正如你所說的那樣,[querySelector **](https://developer.mozilla.org/en-US/docs/Web/API/document .querySelector)不被支持,你還可以將AngularJs的版本縮減爲與IE7「更多」兼容的版本。 - 另外請參閱[**處理IE家族**](http://ng-learn.org/2013/12/Dealing-with-IE-family/),特別支持IE 7的部分。 – Nope 2014-09-12 15:22:47
我有嘗試引導,但沒有運氣,因爲問題是與querySelector對象 – 2014-09-12 15:25:46
我在評論中鏈接了另一篇文章,專注於處理與IE特別是它有一個整體部分在底部,提到shivs,polly-filled等。希望這會有所幫助。 – Nope 2014-09-12 15:28:48