AngularJS - ng-options不起作用

时间:2015-08-11 17:13:25

标签: angularjs ng-repeat ng-options

我有以下data.types

types: Object
  4: "x"
  5: "c"
  9: "y"

我正在尝试这个:

<select ng-options="key as value for (key, value) in data.types">

但是无法填充选择输入。如何使用ng-options代替ng-repeat

2 个答案:

答案 0 :(得分:1)

<select ng-model="yourModel" ng-options="key as value for (key, value) in data.types">

应该工作

答案 1 :(得分:1)

您错过ng-model选择标记。

<select ng-model="yourNgModel" ng-options="key as value for (key, value) in data.types">
</select>

http://jsfiddle.net/414dow6m/