我的其餘調用從數據庫返回數據。我已經分別測試了其他服務調用,並發現它一切正常。當我嘗試在前端顯示它,我得到這個錯誤:無法讀取未定義的屬性「名稱」
'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