簡體   English   中英

Angular JS在IE9上不起作用

[英]Angular JS not working on IE9

我正在嘗試將網頁遷移到有角JS。 它是一個簡單的SPA。 它只有基本組件,如標簽,texbox和下拉列表。 我可以在chrome和Firefox上運行該頁面。 但是,在IE9上,外觀精美的頁面失敗了。 在IE9中,我什至無法使用Angular JS。 頁面加載后,我立即收到以下JS錯誤:

SCRIPT5007:預期對象
angular.js,第318行字符12
SCRIPT438:對象不支持屬性或方法“模塊”
Refernce-module.js,第6行字符1
SCRIPT5007:無法獲取屬性“ controller”的值:對象為null或未定義
Refernce-module-controller.js,第6行字符1

我想提一下,除了ng-app(在html標簽中)和ng-controller(在bodytag中)之外,我在html中沒有使用過任何有角度的JS。

以下是控制器js代碼:

referenceDataMaintainenceApp.controller('referenceDataMaintainenceCtrl', function ($scope) {

$scope.lookup_codes = [
    {'key':'FS_ASSET_CLASS','value':'ASSET CLASS - FS'},
    {'key':'account_actc','value':'Non ASSET CLASS - FS'},
    {'key':'account_fee_type_cd','value':'Account Fee Types'}
];




$scope.change_lookup = function() {
   // console.log(new Date('2014-05-02').getTime());
    var key = $scope.lookup_codes_model.key;
    if(key == 'FS_ASSET_CLASS') {
        $scope.lookup_codes_details = [{'name':'ASSET CLASS','description':'Testing the code lookup module for ASSET CLASS.', 'active':true}];
    } else {
        $scope.lookup_codes_details = [];
    }
};


$scope.addLookupCode = function() {

    $scope.lookup_codes_details.push($scope.new_lookup_code);
    $scope.new_lookup_code = getLookupCodeObject();


};

/*----------------------benchmark-----------------------------*/      

$scope.benchmarks_details = [{'name':'Bench 1','description':'BenchMark 1', isNew : false},
                             {'name':'Bench 2','description':'BenchMark 2', isNew : false}];

$scope.addBenchMark = function() {

    $scope.benchmarks_details.push($scope.new_benchmark);
    $scope.new_benchmark = getBenchMarkObject();

  };




  /*----------------------holidays-----------------------------*/    

$scope.calendar_countries = [
                            {'key':'AUST','value':'AUSTRALIA'},
                            {'key':'CANADA','value':'CANADA'},
                            {'key':'CHINUK','value':'CHINA UK'}
                           ];
$scope.calendar_years = [
                            {'key':'2012','value':'2012'},
                            {'key':'2013','value':'2013'},
                            {'key':'2014','value':'2014'}
                        ];

$scope.change_holiday = function() {
    var calendar = $scope.calendar_countries_model;
    var year     = $scope.calendar_years_model;
    if(angular.isUndefined(calendar) || 
            angular.isUndefined(year))
        return;
    else {
        if(calendar.key == 'AUST' && 
                year.key == '2014') {
            $scope.calendar_details = [{'date':'1388620800000','description':'New Year', isdelete : false},
                                         {'date':'1398988800000','description':'May Day', isdelete : false}];
        }
        else {
            $scope.calendar_details = [];
        }
    }
    //console.log($scope.calendar_years_model);

};


$scope.addHoliday = function() {

    $scope.calendar_details.push($scope.new_holiday);
    $scope.new_holiday = getHolidayObject();


};


/*----------------------User Defined PAM Fields-----------------------------*/    

$scope.data_types = [
                            {'key':'date','value':'Date'},
                            {'key':'float','value':'Float'},
                            {'key':'int','value':'Integer'}
                           ];
$scope.pam_screens = [
                            {'key':'account_select','value':'Account Details'},
                            {'key':'fund_select','value':'Fund Detail'}
                      ];

$scope.pams_fields = [{'name':'Benchmark Tolerance','label':'Benchmark Tolerance', 'type':'Date', 'screen': 'fund_select','active':true}];

$scope.addUsedDefPAMFields = function() {

    $scope.pams_fields.push($scope.new_pam_field);
    $scope.new_pam_field = getUserDefinedPamFieldsObject();


};

/*----------------------Broker Code Maintainence-----------------------------*/    


$scope.brokers_details = [{'name':'000200','description':'GREENWICH OPTIONS COMPANY', 'active':true},
                          {'name':'000202','description':'WEISS PECK AND GREER LLC', 'active':false}];

$scope.addBrokerCodes = function() {

    $scope.brokers_details.push($scope.new_brokers_detail_list);
    $scope.new_brokers_detail_list = getBrokerCodeObject();


}; 


});

function getLookupCodeObject () {

lookup_code = {
        name :  '', 
        description : '',
        active : false
};

return lookup_code;
}

function getBenchMarkObject () {

benchmark = {
        name :  '', 
        description : '',
        isNew : false
};

return benchmark;
}

function getHolidayObject () {

holiday = {
        date :  '', 
        description : '',
        isdelete : false
};

return holiday;
}

function getUserDefinedPamFieldsObject () {

pam_fields = {
        name :  '', 
        label : '',
        type : '',
        sceen : '',
        active : false
};
return pam_fields;
}

function getBrokerCodeObject () {

broker_code = {
        name :  '', 
        description : '',
        active : false
};
return broker_code;
}

以下是模塊js代碼:

var referenceDataMaintainenceApp = angular.module('referenceDataMaintainenceApp', [] );

請指導我解決此瀏覽器問題。

謝謝

查看包含Angular.js,refernce-module.js和refernce-module-conroller.js的位置的HTML代碼將很有幫助。 因為從錯誤消息中我猜出angular關鍵字無法正確識別,因此.module,referenceDataMaintainenceApp分配和.controller無法正常工作。

也許這個線程可能有所幫助。

似乎某些ECMA5功能無法在IE9中使用。 我一直在IE8中移植AngularJS應用程序以測試其兼容性,您也可以嘗試以下提示,這些提示對我有幫助:

  1. ES5 ShimES5 Sham (需要Object.Create polyfill)
  2. JSON3 polyfill用於JSON處理
  3. 使用Angular 1.2.x,該版本可在IE8之前無縫運行
  4. 使用jQuery 1.xx
  5. 始終 AngularJS 之前包含jQuery,因為Angular傾向於使用自己的jQueryLite,這可能會在舊的瀏覽器中導致錯誤

希望能幫助到你!

發生此問題的原因是AngularJS代碼的某些部分最初與IE9不兼容。 我遇到了同樣的問題,您需要做的就是 AngularJS 之前的應用程序中導入es5-shim ,如下所示:

<!--[if lte IE 9]>
    <script src="lib/es5-shim/es5-shim.min.js"></script>
    <script src="lib/es5-shim/es5-sham.min.js"></script>
<![endif]-->
<script src="lib/angular/angular.min.js"></script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM