【发布时间】:2018-08-15 14:15:50
【问题描述】:
我面临一个问题,即 angularjs 数据表正确显示但在刷新视图后无法显示。有时我可以毫无问题地刷新视图 2-10 次,而其他时候只需要刷新一次就不会完全显示。
下面是控制视图特定部分的代码:
<div ng-show="selectedSubmissionTab_Upload.batchProcessStatistics[0].batchStatus.statusDescription == 'Failure' && selectedSubmission_Upload">
<h5 style="top: 35px; display: inline-block; position: relative; width: 100%; color: #1965A8; padding: 10px 10px 0px 10px; font-weight: bold;">Submission Issues
<label style="float: right; color:#d9534f; display: inline-block;">Total Errors
<span>{{selectedSummaryItem.batchMessages.length}}</span>
</label>
</h5>
<div>
<table datatable="ng" class="row-border hover agsTable" style="width: 100%">
<thead>
<tr class="tableHead">
<th>
Row
</th>
<th>
Column
</th>
<th>
Message
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in selectedSummaryItem.batchMessages" ng-class-odd="'odd'" ng-class-even="'even'">
<td>{{item.dataRow}}</td>
<td>{{item.dataColumn}}</td>
<td>{{item.message}}</td>
</tr>
</tbody>
</table>
<button type="button" class="btn btn-link btn-sm pull-right" ng-click="downloadBatchErrors()" style="position:relative; top: -40px;">Download Error List</button>
</div>
</div>
</div>
以及与之交互的js代码:
function getSubmissionSummary(calPk, companyPk) {
HomeFactory.getSubmissionSummary(calPk, companyPk)
.then(function (response) {
$scope.submissionSummaryList = response.data;
console.log('Summary response: ' + $scope.submissionSummaryList);
for(i=0;i<$scope.submissionSummaryList.length;i++){
if($scope.selectedTaskSubmissionPk == $scope.submissionSummaryList[i].submissionPk){
$scope.selectedSummaryItem = $scope.submissionSummaryList[i];
console.log('Assigning: '+$scope.selectedTaskSubmissionPk +' to '+$scope.submissionSummaryList[i].submissionPk);
console.log('Selected submission summary item: '+$scope.selectedSummaryItem.numRows);
break;
}
}
}, function (error) {
console.log('Error ' + JSON.stringify(error));
if (error.status == 401) {
window.location.href = $scope.baseUrl;
}
})
}
控制台日志记录是我试图查看是否分配了正确的值,我可以确认它们是正确的。
当表格加载时,它看起来像这样:
当它无法加载表格时,它看起来像这样:
从第二张图片可以看出,要加载到表格上的数组已被识别,但表格本身并未显示。为解决此问题提供帮助和建议将不胜感激!
【问题讨论】:
标签: angularjs