Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何从多个选择框中获取选择值数组?_Angularjs_Select_Html Table_Angularjs Ng Change - Fatal编程技术网

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>