I am trying to do something similar to what this question is doing, getting the length and totals of my filtered results.
HTML:
<div ng-app="app" ng-controller="controller">
<div class="col-md-4 ">Filter: <input class="form-control" ng-model="dataFilter" placeholder="filter" /></div>
<div class="col-md-4 ">Total: {{filtered.length}}</div>
<table class="table table-hover" ts-wrapper>
<thead>
<tr>
<th ts-criteria="policy.policy_number | parseInt">
Policy
</th>
<th ts-criteria="sales_rep.name">
Sales Rep
</th>
<th ts-criteria="policy.customer.full_name">
Customer
</th>
<th ts-criteria="type">
Type
</th>
<th ts-criteria="change_amt | parseFloat">
Change Amount
</th>
<th ts-criteria="effective_date | date">
Effective Date {{filtered.length}}
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="transaction in filtered = (data | filter: dataFilter )" ts-repeat>
<td>{{transaction.policy.policy_number}}{{pizza}}</td>
<td>{{transaction.sales_rep.name}}</td>
<td>{{transaction.policy.customer.full_name}}</td>
<td>{{transaction.transaction_type}}</td>
<td>${{transaction.change_amt | number:currency}}</td>
<td>{{transaction.effective_date | date}}</td>
</tr>
</tbody>
</table>
</div>
The JS really has nothing specific to this. In the above example {{filtered}}
displays the filtered results as expected only when within the table (in the <th>
in this case). When I try to get the length up above in the div, it returns nothing.
Is some kind of isolated scope being created here? My code appears to match the example the SO question had that I linked above so how come they can access that variable in other elements and I cannot?