使用智能表的angularjs分页

标签 angularjs smart-table

通过使用 Angular 智能表,如何使用偏移值获取结果集。
例如,我在数据库中有 100 条记录

  • 首先,我需要从数据库中获取 20 条记录,并且每页仅显示 10 个项目。
  • 点击第三页后,需要查询数据库(服务调用)并获取另外20条记录..等(但第二页没有服务器调用)

  • 我正在使用智能表管道/ajax 插件来显示记录。

    如何使用这个实现。
    <div class="table-container" ng-controller="pipeCtrl as mc">
                <table class="table" st-pipe="mc.callServer" st-table="mc.displayed">
                    <thead>
                    <tr>
                        <th st-sort="id">id</th>
                        <th st-sort-default="reverse" st-sort="name">name</th>
                        <th st-sort="age">age</th>
                        <th st-sort="saved">saved people</th>
                    </tr>
                    <tr>
                        <th><input st-search="id"/></th>
                        <th><input st-search="name"/></th>
                        <th><input st-search="age"/></th>
                        <th><input st-search="saved"/></th>
                    </tr>
                    </thead>
                    <tbody ng-show="!mc.isLoading">
                    <tr ng-repeat="row in mc.displayed">
                        <td>{{row.id}}</td>
                        <td>{{row.name}}</td>
                        <td>{{row.age}}</td>
                        <td>{{row.saved}}</td>
                    </tr>
                    </tbody>
                    <tbody ng-show="mc.isLoading">
                    <tr>
                        <td colspan="4" class="text-center"><div class="loading-indicator"></div>
                        </td>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td class="text-center" st-pagination="" st-items-by-page="5" colspan="4">
                        </td>
                    </tr>
                    </tfoot>
                </table>
            </div> 
    

    http://lorenzofox3.github.io/smart-table-website/

    Plunker 中的代码

    http://plnkr.co/edit/wzUHcc9PBF6tzH8iAEsn?p=preview

    最佳答案

    您需要添加 st-safe-src="tablecollection"以及 st-table=tablerow
    然后,

    <tr ng-repeat="row in tablerow">
    

    FMI,
    来源:Client side pagination not working in smart table

    关于使用智能表的angularjs分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30164481/

    相关文章:

    javascript - Smart-Table 是否可以过滤模糊

    javascript - 表中的 Angular ng-repeat 用数组迭代键

    javascript - 将智能表添加到meanjs堆栈

    javascript - 智能表 st-search 不起作用

    javascript - Protractor 关闭当前选项卡

    angularjs - 在 angular.js 应用程序中全局进行错误处理的最佳方法是什么?

    javascript - "binding"工厂和 Controller 之间

    javascript - 使用 AngularJS 初始化数据表

    angularJS:如何在父作用域中调用子作用域函数

    javascript - 客户端分页在智能表中不起作用