在我的角度SPA中,我使用<select><option ng-repeat...></select>
构造,这样
<div ng-init="hours = [ '9:00', '10:00' ]">
<select name="eta" ng-model="reservation.eta">
<option ng-repeat="hour in hours track by $index" ng-value="hour">{{ 'We arrive at' | translate }} {{hour}}</option>
</select>
</div>
问题在于,在每个value
的{{1}}中,我得到“我们到达HOUR”字符串(与显示的值相同,这是正确的),而不是单独的小时,我想要......
我想念什么?
注意:请不要建议使用option
因为我因为设置所选和禁用的第一个选项(作为占位符)的某些问题而被迫放弃...: - (
答案 0 :(得分:2)
您不需要在此处使用ng值。只需使用价值。
<div ng-init="hours = [ '9:00', '10:00' ]">
<select name="eta" ng-model="reservation.eta">
<option ng-repeat="hour in hours track by $index" value="{{hour}}">{{ 'We arrive at' | translate }} {{hour}}</option>
</select>
</div>