当ng模型搜索放入某些东西时,分页数不会改变



首先,我使用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>

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

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

更多的解释,查看FAQmichaelbromley/angularUtils/

最新更新