当ng-model搜索放置东西时,dirPagination数字不会改变

时间:2016-08-14 10:21:08

标签: angularjs dirpagination

首先,我使用dirPagination。问题是,当我搜索某些内容时,它已正确过滤,但分页编号不会更改,并且还会显示分页中的所有最后一个数字而没有任何更改,我看到某些页面为空,因为它会过滤但页面编号显示。

<div data-ng-controller='productsController'>
    <form `class='form-inline'>
        <div class='form-group'>
            <label>search</label>
            <input type='text' data-ng-model='search' class='form-control' placeholder='search' />
        </div>
    </form>

    <table class='table table-striped'>
        <thead>
            <tr>
                <th>#</th>
                <th>product</th>
                <th>imet</th>
                 </tr>
        </thead>
        <tbody>
            <tr dir-paginate='product in products|itemsPerPage:12|filter:search|orderBy:sortKey:reverse'>
                <td>{{product.id}}</td>
                <td>{{product.productName}}</td>
                <td>{{product.time}}</td>
            </tr>
        </tbody>
    </table>
    <dir-pagination-controls max-size='10' direction-links='true' boundary-links='true' >
    </dir-pagination-controls>
    <script>
        (function(){
        var app = angular.module('products', ['angularUtils.directives.dirPagination']);
        app.controller('productsController', function($scope, $http){
        $scope.products = [];
        $http.get('/products/json').success(function(data){
            $scope.products= data;
        });
    });
    })();
</script>
</div>

1 个答案:

答案 0 :(得分:1)

itemsPerPage必须是最后 filter,如下所示:

<tr dir-paginate='product in products | filter: search | orderBy: sortKey: reverse | itemsPerPage: 12'>

有关详细说明,请在FAQ上的michaelbromley/angularUtils/上查看。