如何显示 table 定义之外的过滤行数?
how to display the number of filtered rows outside table definition?
我已经为我的 ngtable
实现了一个过滤器。尝试像这样显示过滤项目的数量:
如何在此处显示 nr
筛选行?在 table 定义之外?
{{filtered.length}}
个符合过滤器的结果
<table ng-table="tableParams" class="table">
<tr ng-repeat="account in filtered =($data | filter:search.accountName | filter:search.id)">
<td>{{filtered.length}}</td>
<td data-title="'id'">
{{account.account.accountId.id}}
</td>
<td data-title="'name'">
{{account.account.accountName}}
</td>
</tr>
</table>
如果您在子范围内使用数组之前先创建数组,那么它们将引用并使用父范围中的数组
JS
$scope.model = {filtered:[]}
HTML
How to display nr of filtered? {{model.filtered.length}} result(s) matching the filter
<tr ng-repeat="account in model.filtered =($data | filter:search.accountName | filter:search.id)">
只需在 ng-repeat 中的过滤前添加 $parent 就可以了。
Ng-repeat 有一个独立的作用域。
<tr ng-repeat="account in $parent.filtered =($data | filter:search.accountName | filter:search.id)">
使用内置函数:
total() {{ tableParams.total() }}
我已经为我的 ngtable
实现了一个过滤器。尝试像这样显示过滤项目的数量:
如何在此处显示 nr
筛选行?在 table 定义之外?
{{filtered.length}}
个符合过滤器的结果
<table ng-table="tableParams" class="table">
<tr ng-repeat="account in filtered =($data | filter:search.accountName | filter:search.id)">
<td>{{filtered.length}}</td>
<td data-title="'id'">
{{account.account.accountId.id}}
</td>
<td data-title="'name'">
{{account.account.accountName}}
</td>
</tr>
</table>
如果您在子范围内使用数组之前先创建数组,那么它们将引用并使用父范围中的数组
JS
$scope.model = {filtered:[]}
HTML
How to display nr of filtered? {{model.filtered.length}} result(s) matching the filter
<tr ng-repeat="account in model.filtered =($data | filter:search.accountName | filter:search.id)">
只需在 ng-repeat 中的过滤前添加 $parent 就可以了。 Ng-repeat 有一个独立的作用域。
<tr ng-repeat="account in $parent.filtered =($data | filter:search.accountName | filter:search.id)">
使用内置函数:
total() {{ tableParams.total() }}