json - Getting a count of angular repeater matches by attribute? -


i have table built in angularjs 1.35 , json file 100 users. th users have attributes such group, phone, location, etc.

in particular table, wanted parse json file groups users in, , filter unique values. able using angular ui utilities' "unique" filter:

<tr ng-repeat="user in users.users | unique:'group'">     <td><input type="checkbox" value="" ng-model="user.selected"></td>     <td>{{user.group}}</td>     <td>number of users in group?</td>         </tr> 

i have list of groups. want print, in row each group, number of matches group.

in other words, need table such as:

| new york -|- 20 users | | dallas   -|- 10 users | 

etc.

you can create custom count filter , apply filtered lists:

app.filter('count', function() {   return function(items) {     return items.length;   } }); 

html:

<td width="300">{{users | filter:{group:user.group} | count}}</td> 

see in action here.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -