在加载数据期间在表上显示加载/进度/微调框

时间:2018-12-18 10:49:45

标签: javascript angularjs

有一个表由ng_repeat填充,我将在数据加载时显示加载/进度/微调框

 <div class="panel-body panel-success">

                <div class="col-lg-12">
                    <table class="table table-bordered" >
                        <tr>
                            <th>Name</th>
                            <th>Family</th>
                            <th>Age</th>

                        </tr>
                        <tr ng-repeat="r in results  track by r.ID">
                            <td>
                                {{r.Name}}
                            </td>
                            <td>
                                {{r.Family}}
                            </td>
                            <td>
                                {{r.Gender}}
                            </td>

                        </tr>
                        <tfoot>
                            <tr>
                                <td align="center" colspan="8">
                                    <div class="pull-center">
                                        <ul uib-pagination total-items="totalCount" ng-change="pageChanged()"
                                            items-per-page="pageSizeSelected"
                                            direction-links="true" ng-model="pageIndex"
                                            max-size="maxSize"
                                            class="pagination"
                                            boundary-links="true"
                                            rotate="false" num-pages="numPages"></ul>
                                    </div>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>

如何在表中显示正在加载数据的加载/进度/微调器?我想在表格内显示微调框(不是行,而是要保留表格列名称)

1 个答案:

答案 0 :(得分:0)

在未加载数据时显示微调器...一旦加载,将其隐藏!

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>

<div ng-app="soQuestion">
  <div class="panel-body panel-success" ng-controller="soController">
{{results.length}}
    <div class="col-lg-12">
      <table class="table table-bordered">
        <tr>
          <th>Name</th>
          <th>Family</th>
          <th>Age</th>
        </tr>
          <tr ng-if="results.length<1">
            <td>
              //insert the spinner image here
            </td>
            <td>
              //insert the spinner image here
            </td>
            <td>
              //insert the spinner image here
            </td>

          </tr>
        

        <ng-container ng-if="results.length>0">
          <tr ng-repeat="r in results  track by r.ID">
            <td>
              {{r.Name}}
            </td>
            <td>
              {{r.Family}}
            </td>
            <td>
              {{r.Gender}}
            </td>

          </tr>
        </ng-container>


        <tfoot>
          <tr>
            <td align="center" colspan="8">
              <div class="pull-center">
                <ul uib-pagination total-items="totalCount" ng-change="pageChanged()" items-per-page="pageSizeSelected" direction-links="true" ng-model="pageIndex" max-size="maxSize" class="pagination" boundary-links="true" rotate="false" num-pages="numPages"></ul>
              </div>
            </td>
          </tr>
        </tfoot>
      </table>
    </div>
  </div>
</div>