Reputation: 27
enter code hereI have an ng-repeat in my ionic code. It gives me many duplicate values as the data is coming from CSV file. How can I stop this duplicate values from being shown ? Data shows XYZ values more than 5 times but I want it to be shown only once.
<select ng-model="srcstn">
<option ng-repeat="x in from track by $index " >{{x.source}}</option>
</select>
This is piece of code where m getting all duplicate values at {{x.source}}. and x.source has station names
Upvotes: 0
Views: 57
Reputation: 705
Try using 'unique'(aliases: uniq) filter in angular.filter module
usage: colection | uniq: 'property'
you can also filter by nested properties:
colection | uniq: 'property.nested_property'
try
<select ng-model="srcstn">
<option ng-repeat="x in from |uniq:'source'" >{{x.source}}</option>
</select>
Upvotes: 1