我正在尝试将网页迁移到角度JS。它是一个简单的SPA。它只有标签,texbox和下拉列表等基本组件。我可以让页面处理chrome和Firefox。然而,在IE9上看起来非常好看的页面失败了。在IE9中我甚至无法获得角度JS工作。一旦页面加载,我就会听到JS错误:
SCRIPT5007:预期的对象
angular.js,318行12个字符 SCRIPT438:对象不支持属性或方法'模块'
refernce-module.js,第6行第1个字符 SCRIPT5007:无法获取属性的值' controller&#39 ;:对象为空或未定义
refernce-module-controller.js,第6行字符1
我想提一下,我没有在html中使用任何角度JS,除了ng-app(在html标签中)和ng-controller(在bodytag中)。
以下是控制器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', [] );
请指导我修复此浏览器问题。
由于
答案 0 :(得分:1)
查看包含angular.js,refernce-module.js和refernce-module-conroller.js的HTML代码会很有帮助。因为错误消息中我认为angular关键字无法正确识别,因此.module,referenceDataMaintainenceApp赋值和.controller不会工作。
也许this这个帖子可能会有帮助。
答案 1 :(得分:-1)
似乎有些ECMA5功能在IE9中不起作用。我一直在IE8中移植AngularJS应用程序来测试它的兼容性,你也可以尝试以下提示帮助我:
答案 2 :(得分:-1)
出现此问题是因为AngularJS代码的某些部分最初与IE9不兼容。我遇到了同样的问题,你需要做的就是在你的应用之前导入es5-shim 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>