vendredi 28 novembre 2014

Angular ng-repeat for duplicates


I use Angular, this is my view:



<div class="col-sm-6" ng-repeat="contact in service.contacts">

<label class="control-label mb10">{{contact.textDescription | decodeURIComponent}}</label>
<select multiple="multiple" selectize>
<option>{{contact.value}}</option>
</select>

</div>


I have one problem and I can't figure out a way to solve it. For contact.textDescription, I need to put only unique values, so if that contact.textDescription is duplicate, don't create field twice, but add that contact.value to options of that same contact.textDescription which already exists.. So, something like this:



if(contact.textDescription is duplicate) {
contact.value.addTo(contact.textDescription which already exists)
}


Maybe some filter to apply or?





Aucun commentaire:

Enregistrer un commentaire