0

I am trying to get an array of the values of dynamically generated select boxes in a table. How could you get an array or another data type of these values?

Here is the table:

  <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> 

and here is the controller:

function FormActionFieldController($scope, $http, $rootScope) {
  $rootScope.data = null;

  $http.get('http://localhost:82/rs/transformTrigger/formFields')
    .success(function (data, status, headers, config) {
      $rootScope.formFields = data;
  })
  .error(function (data, status, headers, config) {
     //  Do some error handling here
    alert('error FormActionFieldController');
  });
  $rootScope.getFields=function(){  
    $scope.actionFields = null;
    $scope.httpData = '{"actionName":"'+$rootScope.actionTypeName+'"}';

  $http.post('http://localhost:82/rs/transformTrigger/lawsonFields', $scope.httpData)
      .success(function (data, status, headers, config) {
       $scope.actionFields = data;
  })
  .error(function (data, status, headers, config) {
      //  Do some error handling here
  });
  }
  $scope.nextPage=function(){
      $rootScope.page3=false;
      $rootScope.page4=true;
  }
  $scope.lastPage=function(){
    $rootScope.page3=false;
    $rootScope.page2=true;
  }
 $scope.mapValues=function(){
    $rootScope.submitArray = $rootScope.formFields;
    alert($rootScope.submitArray);

  }
 }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Amanda Watson
  • 340
  • 2
  • 3
  • 14
  • What looks like a formField? If you have an id, or a name, you can store datas using ng-model=datas[name]. Using this, you will get an object with selected datas, and you can iterate over it to get the array you want. – Nico Aug 04 '14 at 19:39

1 Answers1

0

you can use $index

<select ng-model="name[$index]" ng-options="item.formField for item in formFields"></select>

this way you get an array of selected values

harishr
  • 17,807
  • 9
  • 78
  • 125