Angularjs表有时显示有时不显示

时间:2018-08-15 05:52:20

标签: angularjs

我遇到一个问题,其中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;
                }
            })
    }

控制台日志记录是我尝试查看是否分配了正确的值,并且可以确认是否正确。

表加载时如下所示:

Table has successfully loaded

当无法加载表时,它看起来像这样:

Table failed to load

从第二张图像中可以看到,可以识别要加载到表上的数组,但是表本身不显示。解决问题的帮助和建议将不胜感激!

1 个答案:

答案 0 :(得分:0)

未加载表时,您的控制台窗口显示什么?有任何错误吗?