Reputation: 869
I have a multiple ui-select widget and i need to update the choices by click on update button.
<ui-select multiple ng-model="multipleDemo.selectedPeople" theme="select2" ng-disabled="disabled" style="width: 800px;">
<ui-select-match placeholder="Select person...">{{$item.name}} <{{$item.email}}></ui-select-match>
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
<div ng-bind-html="person.name | highlight: $select.search"></div>
{{person.email}}
</ui-select-choices>
</ui-select>
If i use array of strings for people variable it works fine. But when i use array of objects then duplicates appears in choices. Here is the snippet http://plnkr.co/edit/Jbhv1stbXEdNnt3of5aW?p=preview How can i avoid duplicates with objects? Help please.
Upvotes: 3
Views: 2306
Reputation: 5025
solution i've found here https://github.com/angular-ui/ui-select/issues/580. You can filter the data you receive from your API.
$scope.people = response.data.data.filter(function (i) {
return $multipleDemo.selectedPeople.map(function (e) { return e.id; }).indexOf(i.id) < 0;
}
Upvotes: 2