Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
94
rated 0 times [  95] [ 1]  / answers: 1 / hits: 20532  / 10 Years ago, thu, july 31, 2014, 12:00:00

I am currently using angular-ui/ui-select in my project. I am able to bind the value of the ui-select to an object without issue, however it is binding the entire item that is being iterated over. I would like to only bind based on the item.codeId this would allow me to persist the correct data as well as display the correct value in the drop down when the page is loaded.



How can I setup ui-select to do this?



<ui-select ng-model=myObject.stateCode id=stateCode>
<ui-select-match placeholder=Select a state...>{{$select.selected.codeDescription}}</ui-select-match>
<ui-select-choices repeat=item in constants.states | filter: $select.search value={{$select.selected.codeId}}>
<div ng-bind-html=item.codeDescription | highlight: $select.search></div>
<small ng-bind-html=item.codeId | highlight: $select.search></small>
</ui-select-choices>
</ui-select>

More From » angularjs

 Answers
8

Your code is fine, but there was a bug that caused this when using a child array (constants.states).



I just fixed this issue at https://github.com/angular-ui/ui-select/pull/131, specifically this commit



New version v0.5.1 released.
If you're using bower, just run bower update.


[#69970] Wednesday, July 30, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleykeyshawnb

Total Points: 281
Total Questions: 99
Total Answers: 111

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
mckinleykeyshawnb questions
;