我需要使用ng-options遍历以下对象:
var a = {
'optionName1': 'optionValue1',
'optionName2': 'optionValue2',
'optionName3': 'optionValue3',
'optionName4': 'optionValue4',
};
我从第三方资源中获得了这种格式的对象,我宁愿不手动重新排列它。
我已经在谷歌上进行了搜索,并查看了文档,它处理的是列表,以及我所能告诉的对象列表。
发布于 2013-09-18 18:14:38
对于这样的模型:
$scope.options = {
'optionName1': 'optionValue1',
'optionName2': 'optionValue2',
'optionName3': 'optionValue3',
'optionName4': 'optionValue4',
};
您可以创建如下选项:
<select ng-change="change()" ng-model="votes.status"
ng-options="v for (k,v) in options">
</select>
https://stackoverflow.com/questions/18869415
复制相似问题