无法将JSON数据加载到AngularJS中的DropDownList中
在使用Angular ng选项将JSON数据加载到下拉列表时,我得到的是空白数据 我的JSON值无法将JSON数据加载到AngularJS中的DropDownList中,angularjs,dropdown,angularjs-ng-options,Angularjs,Dropdown,Angularjs Ng Options,在使用Angular ng选项将JSON数据加载到下拉列表时,我得到的是空白数据 我的JSON值 "tagFormat": { "displayText": "Tag Format", "options": [{ "value": "js", "name": "JS" }, { "value": "vast", "name": "VAST"
"tagFormat": {
"displayText": "Tag Format",
"options": [{
"value": "js",
"name": "JS"
}, {
"value": "vast",
"name": "VAST"
}]
},
HTML视图
<div class="select_padding">
<select class="form-control" ng-options="otf.value as otf.name for otf in details.tagFormat.options">
<option>Select Tag Format</option>
</select>
</div>
选择标记格式
这里是我的范围变量
如何获取这些数据,以及下次我需要使用选定值时。那么我需要绑定ng模型吗
谢谢以下是工作代码:
<select class="form-control" ng-options="item as item.name for item in details.tagFormat.options track by item.value" ng-model="selected">
<option value="">Select Tag Format</option>
</select>
选择标记格式
在$scope.selected
中读取所选项目
在Codepen上检查此示例: