I am populating JSON
data in Select/options. The problem is once user selects an item, value attribute displays the selected JSON
data (including itemID and itemName) rather than just displaying itemName. whats the best possible way to display selected itemName only?
Here is sample data and code:
JSON:
scope.itemData = [{"itemId":1,"itemName":"Glo Light"},
{"itemId":2,"itemName":"Star Light"},
{"itemId":3,"itemName":"Aqua Light"}]
and
Code:
<select ng-model="myItem">
<option ng-repeat="item in itemData" value="item.itemId">
{{item.itemName}}
</option>
</select>
Thanks for your help!
Value in option should be an angular expression.
<select ng-model="myItem">
<option ng-repeat="item in itemData" value="{{item.itemId}}">
{{item.itemName}}
</option>
</select>
<select ng-model="myItem" ng-options="i.itemId as i.itemName for i in itemData"></select>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.