dirPaginate 不适用于 ng-repeat-start(对于可扩展 table)

dirPaginate not working with ng-repeat-start(for expandable table)

我正在使用消耗品 table 因为代码在

下面
<table class="table table-condensed table-bordered">
    <thead>
        <tr>
            <th>
            </th>
            <th>S. No.</th>
            <th>Position</th>
            <th>Reporting to</th>
        </tr>
    </thead>
    <tbody>
        <tr ng-repeat="position in listPositiondtls | itemsPerPage:10" current-page="currentPage">
            <td>
                <button ng-click="expanded = !expanded">
                    <span ng-bind="expanded ? '-' : '+'"></span>
                </button>
            </td>
            <td >{{$index+1}}</td>
            <td>{{position.positionName}}</td>
            <td>{{position.reportingToName}}</td>
        </tr>
        <tr ng-show="expanded">
            <td></td>
            <td colspan="3">
                <div class="col-lg-6 margin_all">
                    <span>Department Code: {{position.depCode}}</span>
                </div>
                <div class="col-lg-6 margin_all">
                    <span>Department Name: {{position.depName}}</span>
                </div>
                <div class="col-lg-6 margin_all">
                    <span>Position Name: {{position.positionName}}</span>
                </div>
                <div class="col-lg-6 margin_all">
                    <span>Is He HOD: 
                        <label>
                            <input type="checkbox" ng-model="position.isHeadofdepartment">
                            <span class="text"></span>
                        </label>
                    </span>
                </div>
            </td>
        </tr>
    </tbody>
</table>

这里我使用 ng-repeat-start 指令来扩展 table。 但分页显示此警报:

Pagination directive: the pagination controls cannot be used without the corresponding pagination directive, which was not found at link time.

和一个错误:

pagination directive: the itemsPerPage id argument (id: __default) does not match a registered pagination-id.

帮帮我,我需要在可扩展 table 中分页。

我认为你有 2 个错误。

  • dirPaginate 需要使用 dir-paginate 而不是 ng-repeat.
  • 您需要使用分页控件directive

要解决您的问题,请执行以下操作:

  • dir-paginate 上更改 ng-repeat ng-repeat="position in listPositiondtls | itemsPerPage:10"
  • 加入html<dir-pagination-controls></dir-pagination-controls>

已修改html

<dir-pagination-controls></dir-pagination-controls> 
<table class="table table-condensed table-bordered">
<thead>
    <tr>
        <th>
        </th>
        <th>S. No.</th>
        <th>Position</th>
        <th>Reporting to</th>
    </tr>
</thead>
<tbody>
    <tr dir-paginate="position in listPositiondtls | itemsPerPage:10" current-page="currentPage">
        <td>
            <button ng-click="expanded = !expanded">
                <span ng-bind="expanded ? '-' : '+'"></span>
            </button>
        </td>
        <td >{{$index+1}}</td>
        <td>{{position.positionName}}</td>
        <td>{{position.reportingToName}}</td>
    </tr>
    <tr ng-show="expanded">
        <td></td>
        <td colspan="3">
            <div class="col-lg-6 margin_all">
                <span>Department Code: {{position.depCode}}</span>
            </div>
            <div class="col-lg-6 margin_all">
                <span>Department Name: {{position.depName}}</span>
            </div>
            <div class="col-lg-6 margin_all">
                <span>Position Name: {{position.positionName}}</span>
            </div>
            <div class="col-lg-6 margin_all">
                <span>Is He HOD: 
                    <label>
                        <input type="checkbox" ng-model="position.isHeadofdepartment">
                        <span class="text"></span>
                    </label>
                </span>
            </div>
        </td>
    </tr>
</tbody>