使用angularjs数据类型的json下拉选项正在附加
drop down options from json using angularjs data type is appending
在AngularJS中用JSON填充select,带有ng个选项,
<select id="routeName-{{$index}}" ng-model="row.routeName" ng-options="routeName.id as routeName.name for routeName in routeNames" ng-change="flowRootChange($index)" style="width: 115px;"></select>
输入JSON如下:
scope.routeNames=[{"id":"1","name":"routeName1"},{"id":"2","name":"routeName2"}];
但在html中显示如下:
<select style="width: 115px;" ng-change="flowRootChange($index)" ng-options="routeName.id as routeName.name for routeName in routeNames" ng-model="row.routeName" id="routeName-0" class="ng-pristine ng-valid ng-touched">
<option label="routeName1" value="string:1">routeName1</option>
<option label="routeName2" value="string:2">routeName2</option>
</select>
通过使用JQuery读取数据,我得到了string:2
作为输出。
console.log($("#routeName-"+rowid +" :selected").val());
我不能使用ng-model
/$scope.row.routeName
,因为这个下拉列表在表中。如何在不使用split()方法的情况下读取所选值(没有string:
)?。我使用的是"AngularJS v1.4.8"变体。
您可以使用ng repeat而不是ng选项
<select style="width: 115px;" ng-change="flowRootChange($index)" ng-model="row.routeName" >
<option ng-repeat='routeName in routeNames' label="routeName{{ routeName.id }}" value="{{ routeName.id }}">{{ routeName.name }}</option>
</select>
检查这个:-
<select style="width: 115px;" ng-change="flowRootChange($index)" ng-model="name" >
{{routeName.name}}
相关文章:
- AngularJs列表ng单击以选择选项转换
- 如何使用AngularJs禁用ng选项中的选项
- 如何放置'选择'基于angularJS中数据的html选项
- 如何将ng选项的索引作为angularJs中的值传递给模型
- AngularJS ng选项在选择一个选项后删除了默认的空白值
- 当使用select作为标签时,如何使用ng选项禁用angularjs中的选项
- Angularjs-设置不带ng选项的select的默认值
- LEAFLET地图和带有选择选项的标记-ANGULARjs
- 使用 AngularJS 设置活动选项卡样式
- AngularJS 指令的动态选项
- AngularJS选项卡集中的Chart.js不呈现
- AngularJS$作用域在选项卡集中出现问题
- AngularJS-选择选项并在函数中使用它
- AngularJS模型在手动更改选项后不会更新
- AngularJS:点击选项卡刷新视图中的数据
- 在AngularJS Dropdownlost中设置默认文本选项
- checkbox options=选择选项-angularjs
- ng-Options 编辑选项 - AngularJS
- 在选择框中选择默认选项- AngularJs
- 将select重置为特定选项AngularJs和Javascript/JQuery