2014-09-12 111 views
3

我在現有的asp.net項目中引入了angularjs,並且項目中有很多語句只能在IE 7兼容模式下工作,但是當我運行該項目,我對這個問題有點[R & d後收到以下錯誤從angularjs文件IE 7中的Angularjs錯誤對象不支持屬性或方法'querySelector'

Object doesn't support property or method 'querySelector' 

,我想通querySelector從IE 8只介紹

現在我怎樣才能讓我的應用程序工作在IE 7中使用angularjs。?

我不想爲超過7設置元標記,因爲我現有的應用程序依賴於ie 7,它不會在ie 8和以上版本中工作。

我試圖配置角模塊禁用SCE如下:

var rtApp = angular.module("realTimeNotifications", []).config(function($sceProvider) { 
    // Completely disable SCE to support IE7. 
    $sceProvider.enabled(false); 
}); 

但仍沒有運氣。

在此先感謝。

+0

見接受答案:(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

+0

我有嘗試引導,但沒有運氣,因爲問題是與querySelector對象 – 2014-09-12 15:25:46

+0

我在評論中鏈接了另一篇文章,專注於處理與IE特別是它有一個整體部分在底部,提到shivs,polly-filled等。希望這會有所幫助。 – Nope 2014-09-12 15:28:48

回答

0

我也一直在努力與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> 

相關問題