【问题标题】:Angularjs table sometimes shows sometimes it doesn'tAngularjs 表有时显示有时不显示
【发布时间】: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;
                }
            })
    }

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

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

Table has successfully loaded

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

Table failed to load

从第二张图片可以看出,要加载到表格上的数组已被识别,但表格本身并未显示。为解决此问题提供帮助和建议将不胜感激!

【问题讨论】:

    标签: angularjs


    【解决方案1】:

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

    【讨论】:

    • 控制台没有显示错误,只是我在用户消息和消息部分中用于调试的一堆消息。
    • 你能提供演示网址吗?
    • 由于项目的性质,我无法提供演示网址。这是一个相当大的sn-p。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 2015-08-07
    • 2018-05-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多