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>