angularjs - Multiple Filtered Counts with Angular -


i have list of users each of stores [model.stores.users] in json object , show number of users against each store accessing store.users.length

now want 2 counts, these counts based on number of users simple boolean filter.

  • count of active users user.is_user_active = true
  • count of pending users user.is_user_active = false

psuedo code

<div class="table-responsive">     <table class="table table-hover">         <thead>             <tr>                 <th class="hidden">id</th>                 <th>name</th>                 <th>users</th>             </tr>         </thead>         <tbody class="tbl-jobs-data" ng-repeat="item in model.stores">             <tr data-toggle="collapse" class="accordion-toggle" data-target="#store_user{{$index}}">                 <td class="hidden">{{item.id}}</td>                 <td class="">{{item.name}}</td>                 <td class="user-count">{{item.users.length}}</td>             </tr>             <tr ng-if="item.users.length > 0">                 <td colspan="100" class="hiddenrow">                     <div class="accordian-body collapse" id="store_user{{$index}}">                         <table class="table">                             <thead>                                 <tr>                                     <th>id</th>                                     <th>name</th>                                     <th>state</th>                                     <th>is active</th>                                     <th>last login</th>                                 </tr>                             </thead>                             <tbody class="tbl-search-data">                                 <tr ng-repeat="app in item.users">                                     <td>{{app.id}}</td>                                     <td>{{app.name}}</td>                                     <td>{{app.state}}</td>                                     <td>{{app.is_user_active}}</td>                                     <td>{{app.last_login}}</td>                                 </tr>                             </tbody>                         </table>                     </div>                 </td>             </tr>         </tbody>     </table> </div> 

sample output

just use filter, eg

<td class="active_user_count">     {{ (item.users | filter : { is_user_active: true }).length }} </td> <td class="pending_user_count">     {{ (item.users | filter : { is_user_active: false }).length }} </td> 

i hope i've got syntax right, angular docs down @ moment >:(


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -