This question already has an answer here:
- How to get unique values in an array 28 answers
I have a very simple array that has duplicate values. My array is like this:
$scope.type= ["Bar", "Pie", "Line", "Line", "Line", "Line", "Line", "Line", "map", "Line", "Bar", "Pie", "Pie", "Pie", "Pie", "Pie", "Pie", "Pie"]
in my ng-repeat, I have this condition
ng-repeat = types in type track by $index
How can I display only the unique values from my array in ng-repeat?
Try this loop :
To achieve expected result first sort and then filter with ng-if
code sample - https://codepen.io/nagasai/pen/bvVMvV
You can use
unique
filter while usingng-repeat
.Use lodash for convert your array to unque element array
To use loadsh you need to use cdn for lodash
https://lodash.com/docs/4.17.5#uniq
If you don't want to include Lodash, you can do this: