【发布时间】:2014-12-16 09:25:33
【问题描述】:
我正在尝试将网页迁移到 Angular JS。它是一个简单的SPA。它只有标签、texboxes 和下拉菜单等基本组件。我可以让页面在 chrome 和 Firefox 上运行。然而,完美的页面在 IE9 上失败了。在 IE9 中,我什至无法让 Angular JS 工作。页面加载后,我会收到以下 JS 错误:
SCRIPT5007:预期对象
angular.js,第 318 行字符 12
SCRIPT438:对象不支持属性或方法“模块”
引用-module.js,第 6 行字符 1
SCRIPT5007:无法获取属性“控制器”的值:对象为空或未定义
参考模块控制器.js,第 6 行字符 1
我想提一下,除了 ng-app(在 html 标签中)和 ng-controller(在 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;
}
以下是模块js代码:
var referenceDataMaintainenceApp = angular.module('referenceDataMaintainenceApp', [] );
请指导我解决此浏览器问题。
谢谢
【问题讨论】:
-
你的 angularjs 库的版本号是多少?
-
@Tyler.z.yang : v1.3.6
-
您应该尝试使用 1.2.x,m 版本,因为 1.3 版本不再支持 IE8,所以它可能会对 IE9 产生一些后果,docs.angularjs.org/guide/ie
-
您是否也可以尝试在 IE9 中的 jsfiddle 中运行您的代码,如果仍然失败,请给我们一个链接?还是更简单的版本?
标签: javascript html angularjs