使用ng-repeat如何使用angularjs显示默认选定值
我的代码: 我有货币:
"currencies":["AWG","BAM","BBD","BDT","BGN","BHD"]
selected currency is "BBD"
在我的HTML中
<select ng-init='toCurrencyCode = currency.toCurrencyCode' ng-model= 'toCurrencyCode' ng-options="toCurrencyCode as code for code in currencies">
</select>
如果我这样写,则表示默认情况下选择的最后一个值。我需要精确选择的货币。 请更新你的想法。提前谢谢。
答案 0 :(得分:3)
http://plnkr.co/edit/lSu1M58gMtqlOCsaCCrG?p=preview
<select ng-init='toCurrencyCode = currency.toCurrencyCode' ng-model= 'toCurrencyCode'
ng-options="code for code in currencies">