小编DeK*_*arf的帖子

使用$ http.get进行ngTableParams分页

在AngularJS项目上工作,我遇到了以下问题:

使用本地存储/硬编码数据时,分页工作正常.使用远程存储的数据时,分页无法正常工作.

我搜索了很多,但找不到我的问题的解决方案,所以这里是代码snippits:

HTML:

<div ng-controller="ngTableCtrl">
    <p><strong>Pagina:</strong> {{tableParams.page()}}</p>
    <p><strong>Aantal weergegeven:</strong> {{tableParams.count()}}</p>

    <table ng-table="tableParams" class="table table-striped" template-pagination="custom/pager">
        <tr ng-repeat="x in names">
            <td data-title="'Name'">{{x.Name}}</td>
            <td data-title="'City'">{{x.City}}</td>
            <td data-title="'Country'">{{x.Country}}</td>
        </tr>
    </table>

    <script type="text/ng-template" id="custom/pager">
        <ul class="pager ng-cloak">
            <li ng-repeat="page in pages"
                ng-class="{'disabled': !page.active, 'previous': page.type == 'prev', 'next': page.type == 'next'}"
                ng-show="page.type == 'prev' || page.type == 'next'" ng-switch="page.type">
                <a ng-switch-when="prev" ng-click="params.page(page.number)" href="">&laquo; Previous</a>
                <a ng-switch-when="next" ng-click="params.page(page.number)" href="">Next &raquo;</a>
            </li>
            <li>
                <div class="btn-group">
                    <button type="button" ng-class="{'active':params.count() == 2}" ng-click="params.count(2)" class="btn btn-default">2</button>
                    <button type="button" …
Run Code Online (Sandbox Code Playgroud)

pagination http angularjs ngtable

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

angularjs ×1

http ×1

ngtable ×1

pagination ×1