Reputation: 355
I have list that is returning category
and subcategory
and displaying it using ng-repeat
but I want to display the category only once.
<div ng-repeat="item in allocationList">
<p>Category:{{item.Category}}</p>
<p>SubCategory:{{item.subCategory}}</p>
</div>
Upvotes: 0
Views: 1153
Reputation: 5891
Include below scripts inside *.html file:
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0/angular.min.js"></script>
<script src="bower_components/angular-filter/dist/angular-filter.min.js"></script>
Change your module definition statement to:
var myApp = angular.module('myApp', ['angular.filter']);
And retrieve item as shown below:
<div ng-repeat="item in allocationList | unique:'category'">
<p>Category:{{item.Category}}</p>
<p>SubCategory:{{item.subCategory}}</p>
</div>
I hope it helped :)
Upvotes: 2