我的其余调用从数据库返回数据。我已经分别测试了其他服务调用,并发现它一切正常。当我尝试在前端显示它,我得到这个错误:无法读取未定义的属性“名称”
'TypeError: Cannot read property 'name' of undefined
当我调试使用铬我注意到了错误信息,但无法弄清楚问题出在哪里。
控制器
mdmApp.controller('draftReportTypeCalendarController', function($scope, $http, $location, $routeParams) {
$scope.isSelected = false;
$scope.buttonsDisabled = false;
$scope.showSpinner = true;
// TODO: routeParam reportTypeYear
$http.get("/mdmservice/services/draftReportTypeCalendar")
.success(function(data, status, headers, config) {
$scope.draftReportTypeCalendars = data;
if (data.errorMessage != null) {
$scope.error = true;
$scope.success = false;
$scope.errorMessage = data.errorMessage + ". [Error code : " + data.errorCode + "].";
$scope.buttonsDisabled = true;
} else {
$scope.error = false;
if($scope.draftReportTypeCalendars.length == 0){
$scope.warn = true;
$scope.warnMessage = "No records found."
}
//$scope.success = true;
//$scope.successMessage = "To be decided"
$scope.buttonsDisabled = false;
}
}
)
.error(function(data, status, headers, config, statusText) {
$scope.error = true;
$scope.errorMessage = "A system error occured. Please contact EBA IT Helpdesk."
$scope.buttonsDisabled = true;
})
.finally(function() {
$scope.showSpinner = false;
});
$scope.gridOptions = {
paginationPageSizes: [23, 50, 100, 200, 300, 400, 500, 1000],
paginationPageSize: 23,
};
$scope.gridOptions.data = 'draftReportTypeCalendars';
$scope.gridOptions.enableFiltering = true;
$scope.gridOptions.enableGridMenu = true;
$scope.gridOptions.fastWatch = true;
$scope.gridOptions.multiSelect = false;
$scope.gridOptions.columnDefs = [
{
name : "referenceDate", width : "15%"
},
{
name : "reportType", width : "10%"
},
{
name : "entityName", width : "35%"
}
];
$scope.gridOptions.onRegisterApi = function(gridApi){
// set gridApi on scope
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope,function(row){
$scope.selectedId = row.entity.entityId;
$scope.isSelected = row.isSelected;
});
};
浏览器日志
TypeError: Cannot read property 'name' of undefined
at Grid.buildColumns (ui-grid.js:4436)
at columnDefsWatchFunction (ui-grid.js:3176)
at ui-grid.js:3162
at Scope.$digest (angular.js:16664)
at Scope.$apply (angular.js:16928)
at done (angular.js:11266)
at completeRequest (angular.js:11464)
at XMLHttpRequest.requestLoaded (angular.js:11405)
你可以发布相关的堆栈跟踪日志吗? – iulian
添加我的浏览记录 – SGN