3

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}} &lt;{{$item.email}}&gt;</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.

0

1 Answer 1

2

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; 
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.