Lets say I have want to edit an existing entity that has an array of values that are also part of the selectable values. e.g.
var preSelectedLanguages = [
{id: 2, iso: "de"},
{id: 3, iso: "fr"}
]
var languages = [
{id: 1, iso: "en"},
{id: 2, iso: "de"},
{id: 3, iso: "fr"},
{id: 4, iso: "it"},
{id: 5, iso: "us"}
]
My ui-select directive would be something like:
<ui-select multiple ng-model="preSelectedLanguages">
<ui-select-match placeholder="Select language...">
{{$item.iso}}
</ui-select-match>
<ui-select-choices repeat="l in languages track by language.id">
{{language.iso}}
</ui-select-choices>
</ui-select>
However the ui-select-choices
option list cant seem to remove the duplicates, even though I have used track by language.id
.
Any idea how to do this correctly?
It works for me in this way
<ui-select multiple ng-model="preSelectedLanguages">
<ui-select-match placeholder="Select language...">
{{$item.iso}}
</ui-select-match>
<ui-select-choices repeat="l in languages track by l.id">
{{l.iso}}
</ui-select-choices>
</ui-select>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With