Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

ui-select-choices should allow object (hashtable) instead of array of objects #1386

Closed
kutyel opened this issue Jan 14, 2016 · 5 comments
Closed

Comments

@kutyel
Copy link

kutyel commented Jan 14, 2016

I have the following ui-select working:

<ui-select ng-model="vm.example" name="example">
    <ui-select-match placeholder="Select...">{{$select.selected.key}}</ui-select-match>
        <ui-select-choices repeat="x in vm.examples | filter: $select.search">
            <div ng-bind-html="x.key | highlight: $select.search"></div>
    </ui-select-choices>
</ui-select>

And the source for this select is the following array...

vm.examples = [
    {key:'a', value: 1},
    {key:'b', value: 2},
    {key:'c', value: 3}
]

However, I want my "datasource" for the select to be an object literal, as it follows...

vm.examples = {
    a: 1,
    b: 2,
    c: 3
}

I have tried several times and couldn't be able to make it work, is this even possible? If it is not possible due to the ui-select current implementation... _what is the reason??_

@user378230
Copy link
Contributor

Duplicate of #1255

@user378230
Copy link
Contributor

Closing due to lack of activity.

Refer to demo-object-as-source.html for examples of how to do this. (Or see wiki)

@rodneicouto
Copy link

I am adding the initial value. It is selected properly, but disappears from the list. Any idea?

@user378230
Copy link
Contributor

user378230 commented Jul 6, 2016

@rodneicouto #1672 / #1622

@CaledoniaProject
Copy link

demo is broken here
http://angular-ui.github.io/ui-select/demo-object-as-source.html

the dropdown lists are empty

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants