Angularjs 如何从多个选择框中获取选择值数组?
我试图获取表中动态生成的选择框的值数组。如何获取这些值的数组或其他数据类型 这是表格:Angularjs 如何从多个选择框中获取选择值数组?,angularjs,select,html-table,angularjs-ng-change,Angularjs,Select,Html Table,Angularjs Ng Change,我试图获取表中动态生成的选择框的值数组。如何获取这些值的数组或其他数据类型 这是表格: <table> <thead> <tr> <th>Personal Action Field(from Infor-Lawson)</th> <th>Form Fields</th> </tr> </thead> <
<table>
<thead>
<tr>
<th>Personal Action Field(from Infor-Lawson)</th>
<th>Form Fields</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="action in actionFields">
<th>{{action.actionParam}} </th>
<th>
<select ng-model="name" ng-options="item.formField for item in formFields"></select>
Currently selected: {{ name }}
</th>
</tr>
</tbody>
</table>
<br><br>
<button ng-click="lastPage()">Back</button>
<button ng-click="nextPage(); mapValues()">Next</button>
您可以使用$index
<select ng-model="name[$index]" ng-options="item.formField for item in formFields"></select>
通过这种方式,您可以获得一个选定值的数组什么看起来像formField?如果您有id或名称,则可以使用ng model=datas[name]存储数据。使用此选项,您将获得一个包含选定数据的对象,您可以对其进行迭代以获得所需的数组。当我添加$index时,会出现以下错误:TypeError:无法设置未定义的属性“0”。有什么想法吗?请尝试初始化名称。$scope.name=[]
<select ng-model="name[$index]" ng-options="item.formField for item in formFields"></select>