Join the Stack Overflow Community
Stack Overflow is a community of 6.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a UI-Select with Fruits in it the dropDown has FruitID and FruitName data and when i select a choice FruitName appears as SELECTED on dropdown. My question is if i have a FruitID available how can i set the respective value programatically.

Example : Suppose Here is my SampleData in JSON format that is binded to ng-model="SampleData.FruitName"

 FruitID   FruitName  
 1           Apple 
 2           Banana 
 3           Orange 
 4           Mango

Suppose I have "3" as FruitID in a variable and i have to select it by code and i don't know its index in list , is there a way that i can select it and Orange appears as selected in dropdown Here is my sample code

<ui-select ng-model="SampleData.FruitName" theme="bootstrap" reset-search-input="false" >
<ui-select-match allow-clear="true" placeholder="No Fruit Selected" ng-cloak>
  {{$select.selected.FruitName}}
</ui-select-match>
<ui-select-choices repeat="IC in SampleData | filter: $select.search track by $index" ng-cloak>
  {{IC.FruitID}} - {{IC.FruitName}}
</ui-select-choices>

share|improve this question
    
someone ? anyone? – Adeel Saleem Jan 25 at 10:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.