Stefnaister90 Stefnaister90 - 6 months ago 39
AngularJS Question

how to filter repeating data in ng-repeat?

I have repeating members in category list but i must display only non-repeating members with ng-repeat. How to filter this list to display only non-repeating members I have example of code.


Try this:

 <tr ng-repeat="category in cc.categoriesList | unique:category.somefield " ng-click="cc.selectCatForNewTask(category.cid)" ng-class="{selected: cc.getCtgRowClass(category.cid)}">
    <td> {{category.categoryName}} </td> 

You will need to install some dependencies:

1. In your terminal, go to your project and run to install angular-ui-utils unique:

bower install angular-ui-utils#bower-unique

2. Require the unique.js file by adding this to your project below your angular script:

<!-- angular script -->
<script type="text/javascript" src="bower_components/angular/angular.js"></script>
<!-- unique script -->
<script type="text/javascript" src="bower_components/angular-ui-utils/unique.js"></script>

3. Add unique as a module to your app:

angular.module('myApp', ['ui.unique'])

source code available here: AngularUI unique filter