如何呈现以下选项列表的值?AngularJS ng-options not rendering values
$scope.limits = [ {value: '5', text: 'Afficher 5 par page'},
{value: '10', text: 'Afficher 10 par page'},
{value: '15', text: 'Afficher 15 par page'},
{value: '20', text: 'Afficher 20 par page'}
];
<select id="limitType" name="limit" ng-model="limit" ng-options="limit.value as limit.text for limit in limits"></select> enregistrement par page
预期结果(在值= “limit.value” 期待:
<select ng-options="option.value as option.text for option in limits" ng-model="limit" id="limitType" class="ng-pristine ng-valid">
<option value="5" selected="selected">Afficher 5 par page</option>
<option value="10">Afficher 10 par page</option>
<option value="15">Afficher 15 par page</option>
<option value="20">Afficher 20 par page</option>
</select>
结果:
<select ng-options="option.value as option.text for option in limits" ng-model="limit" id="limitType" class="ng-pristine ng-valid">
<option value="0" selected="selected">Afficher 5 par page</option>
<option value="1">Afficher 10 par page</option>
<option value="2">Afficher 15 par page</option>
<option value="3">Afficher 20 par page</option>
</select>
此行为允许使用任何类型的对象中选择选项,不仅是字符串和数字。 –
@bmleite帮助了很多!但是如果我想通过提交表单将值存储在数据库中呢? –