我使用ng-options
的下一个构造:
ng-options="month.id as month.value for month in data.dateList.years"
它给了我带有值的selcet列表:
<option value="0" label="2016">2016</option>
如何为每个选项设置2016而不是value = "0"
?
答案 0 :(得分:1)
<强> HTML 强>
<div ng-app="myapp">
<fieldset ng-controller="FirstCtrl">
<select
ng-options="month.value as month.value for month in year track by month.value"
ng-model="selectedValue"></select>
<br/>
Month is: {{ selectedValue }}
</fieldset>
</div>
<强> JS 强>
var myapp = angular.module('myapp', []);
myapp.controller('FirstCtrl', function ($scope) {
$scope.year =
[{id: 1, value: "January"},
{id: 1, value: "February"}];
});
JSFIDDLE看到它正在运行
答案 1 :(得分:0)
而不是err = _error.message
使用month.id
month.value
答案 2 :(得分:0)
尝试在month.value
month.id
代替ng-options