Ole*_*sov 19 angularjs ng-options
我需要使用ng-options迭代以下对象:
var a = {
'optionName1': 'optionValue1',
'optionName2': 'optionValue2',
'optionName3': 'optionValue3',
'optionName4': 'optionValue4',
};
Run Code Online (Sandbox Code Playgroud)
我从第三方资源获得此格式的此对象,我宁愿不手动重新安排它.
我已经进行了谷歌搜索,并查看了文档,它只处理我可以告诉的对象列表和对象列表.
Alw*_*ner 32
对于这样的模型:
$scope.options = {
'optionName1': 'optionValue1',
'optionName2': 'optionValue2',
'optionName3': 'optionValue3',
'optionName4': 'optionValue4',
};
Run Code Online (Sandbox Code Playgroud)
您可以创建如下选项:
<select ng-change="change()" ng-model="votes.status"
ng-options="v for (k,v) in options">
</select>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9951 次 |
| 最近记录: |