Javascript 我不在IE9上工作

Javascript 我不在IE9上工作,javascript,html,angularjs,Javascript,Html,Angularjs,我正在尝试将网页迁移到angular JS。这是一个简单的水疗中心。它只有标签、文本框和下拉列表等基本组件。我可以让页面在chrome和Firefox上运行。然而,在IE9上,完美美观的页面失败了。在IE9中,我甚至不能让它工作。页面加载后,我会收到以下JS错误: SCRIPT5007:需要对象 angular.js,第318行字符12 SCRIPT438:对象不支持属性或方法“模块” reference-module.js,第6行字符1 SCRIPT5007:无法获取属性“controller

我正在尝试将网页迁移到angular JS。这是一个简单的水疗中心。它只有标签、文本框和下拉列表等基本组件。我可以让页面在chrome和Firefox上运行。然而,在IE9上,完美美观的页面失败了。在IE9中,我甚至不能让它工作。页面加载后,我会收到以下JS错误:

SCRIPT5007:需要对象
angular.js,第318行字符12
SCRIPT438:对象不支持属性或方法“模块”
reference-module.js,第6行字符1
SCRIPT5007:无法获取属性“controller”的值:对象为null或未定义
reference-module-controller.js,第6行字符1

我想提到的是,除了ng应用程序(在html标记中)和ng控制器(在bodytag中),我没有在html中使用任何angular 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;
}
var referenceDataMaintainenceApp = angular.module('referenceDataMaintainenceApp', [] );
下面是模块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;
}
var referenceDataMaintainenceApp = angular.module('referenceDataMaintainenceApp', [] );
请指示我修复此浏览器问题


谢谢

如果您能看到包含angular.js、reference-module.js和reference-module-conroller.js的HTML代码,那会很有帮助。因为在错误消息中,我猜angular关键字没有被正确识别,因此.module、ReferenceDataMaintenanceApp分配和.controller无法工作


也许这个线程会有所帮助。

看起来有些ECMA5功能在IE9中不起作用。我一直在IE8中移植AngularJS应用程序以测试其兼容性,您也可以尝试以下帮助我的技巧:

  • 和(对象需要。创建多边形填充)
  • 用于JSON处理的polyfill
  • 使用Angular 1.2.x,它可以无缝工作到IE8
  • 使用jquery1.x.x
  • 始终在AngularJS之前包含jQuery,因为AngularJS有自己的jQueryLite,它倾向于使用它,这可能会在旧浏览器中导致错误

  • 希望有帮助

    出现此问题是因为AngularJS代码的某些部分最初与IE9不兼容。我遇到了同样的问题,您需要做的就是在
    AngularJS之前导入应用程序,如下所示:

    <!--[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>
    
    
    
    你的angularjs库的版本号是多少?@Tyler.z.yang:它是v1.3.6,你应该尝试使用1.2.x版,因为1.3版IE8已经不受支持了,所以IE9可能会有一些问题,你是否也可以尝试在IE9的JSFIDLE中运行你的代码,如果仍然失败,请给我们一个链接?还是更简单的版本?