目前我正在尝试使用 ng-options 指令加载一个选择框。
但是我无法更改创建选项的值,它只是从 0 到 3,而我希望这些值与我通过的“eigenschap_id”相同。
所以它的值应该是 23-26 而不是 0-3
它哪里出错了?
这是我正在使用的代码。
控制器:
$scope.eigenschappen.game = categories.Game;
Jsonstring/对象:
[{"cat_id":6,"cat_name":"Game","eigenschap_name":"RPG","eigenschap_id":23},{"cat_id":6,"cat_name":"Game","eigenschap_name":"Strategie","eigenschap_id":24},{"cat_id":6,"cat_name":"Game","eigenschap_name":"Avontuur","eigenschap_id":25},{"cat_id":6,"cat_name":"Game","eigenschap_name":"Simulatie","eigenschap_id":26}]
html视图
<select data-ng-options="i.eigenschap_id as i.eigenschap_name for i in eigenschappen.game" ng-model="chosen"></select>
生成的html
<select ng-model="chosen" data-ng-options="i.eigenschap_id as i.eigenschap_name for i in eigenschappen.game" class="ng-pristine ng-valid">
<option value="?" selected="selected"></option>
<option value="0">RPG</option>
<option value="1">Strategie</option>
<option value="2">Avontuur</option>
<option value="3">Simulatie</option>
</select>