Angularjs - ng-model在使用ng-repeat和ng-selected时不适用于select

时间:2017-08-25 11:41:45

标签: angularjs angularjs-select

我已将选项中的ng-repeat设置为ng-selected,但选项未被选中,当我从select all中删除ng-model时,

HTML code:

<select ng-model="formData.value">
<option value="{{item.value}}" ng-selected="{{((item.value).indexOf(formData.value) != -1 ? true:'')  == formData.value}}" ng-repeat="item in levels">{{ item.name}}</option>
</select>

控制器代码:

$scope.levels= [
{"value": ["1", "2", "3"],"name": "High"}, 
{"value": ["4", "5", "6"],"name": "Medium"},
{"value": ["7", "8", "9"],"name": "Low"}
]

我在这里做的是,如果formData.value介于1到3之间,我想用高级显示下拉字段...

它的工作正常没有ng-model名称,但是我想从用户那里获取一个值并将其保存在数组中。在这种情况下,下拉列表不会显示所选字段...

0 个答案:

没有答案