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
Post a Comment