angularjs需要获取过滤项的数量

时间:2014-01-27 19:57:24

标签: angularjs

我有一个项目,我根据预定义的条件(即批准或待定)对数据进行分类。但我也在使用页面选择。我的问题是我无法获得正确数量的对象与程序显示适当的页面数量(总是有额外的页面,因为它需要全部金额而不是过滤量)所以我知道我需要以某种方式得到的数量过滤的对象以显示正确的页面数量。有人可以解释一下吗?

过滤

               <select class="form-control" ng-model="filterType"
                ng-options="pages for pages in filterSelection"
                ng-change="filterAmount()"
                ng-init="filterType=filterSelection[1]">

            </select>

每页的页数:

               <select ng-model="itemperpage"
                class="form-control" ng-options="pages for pages in selection"
                ng-init="itemperpage=selection[0]"></select>
            <pagination total-items="max" page="currpage"
                items-per-page="itemperpage" max-size="maxSize"
                class="pagination-sm" rotate="false" num-pages="numPages"></pagination>
        </div>

实际表格

        <table
            class="table table-hover table-striped table-bordered table-condensed col-md-1">
            <tr>
                <th>Employee Name
                <th>Period</th>
                <th>Status</th>
                <th>Regular Hours</th>
                <th>Overtime Hours</th>
                <th>Total Hours</th>
                <th>Attachment</th>
                <th>Client</th>
                <th>Approve</th>
                <th>Deny</th>
            </tr>
            <tr ng-repeat="employee in (filteredItems = (timeSheets|filter:filterType))" ng-if="$index>=((currpage-1)*itemperpage) && $index<((currpage)*itemperpage)">
                <td>{{employee.name}}</td>
                <td>{{employee.period}}</td>
                <td>{{employee.status}}</td>
                <td>{{employee.regHours}}</td>
                <td>{{employee.overHours}}</td>
                <td>{{employee.totHours}}</td>
                <td><div ng-controller=imageController
                        ng-init="init(employee.username)">
                        <input class="btn btn-primary btn-md btn-block" "type="button"
                            ng-click="imageModal(employee.username,employee.period)"
                            value="View" />
                    </div></td>
                <td>{{employee.Client}}</td>
                <td><input class="btn btn-primary btn-md btn-block"
                    "type="button"
                    ng-click="approveTimesheet(employee.username,employee.period)"
                    ng-disabled="(employee.status=='approved')" value="Approve" /></td>
                <td><input class="btn btn-primary btn-md btn-block"
                    "type="button"
                    ng-click="denyTimesheet(employee.username,employee.period)"
                    value="Deny" /></td>
            </tr>
        </table>
    </div>

使用

解决
<tr ng-repeat="employee in (filteredItems = (timeSheets|filter:filterType))"</tr>
and then in pagination using

<pagination total-items=filteredItems.length page="currpage"
                items-per-page="itemperpage" max-size="maxSize"
                class="pagination-sm" rotate="false" num-pages="numPages"></pagination>
        </div>

0 个答案:

没有答案