Jaydeep Mor
Jaydeep Mor

Reputation: 1703

Write variable value to select element name

I trouble to write variable value to element name.

Here i set dynamic element name,

<tr ng-repeat="row in rowArray">
    <td>
        <select class="form-control" ng-model="allSelect[@{{ row }}]">
            <option ng-repeat="test in [1, 2, 3, 4]" value="@{{ test }}">@{{ test }}</option>
        </select>
    </td>
</tr>

Thank you !

Upvotes: 0

Views: 44

Answers (1)

Slava Utesinov
Slava Utesinov

Reputation: 13488

angular.module('app', []).controller('ctrl', function($scope) {
  $scope.rowArray = ['one', 'two', 'three'];
});
<script src="//code.angularjs.org/snapshot/angular.min.js"></script>

<div ng-app='app' ng-controller='ctrl'>
  <table>
    <tbody ng-init='allSelect={}'>
      <tr ng-repeat="row in rowArray">
        <td>
          <select ng-model="allSelect[row]">
                <option ng-repeat="test in [1, 2, 3, 4]" ng-value="test">
                  {{test}}
                </option>
            </select>
        </td>
      </tr>
    </tbody>
  </table>
  allSelect: {{allSelect | json}}
</div>

Upvotes: 1

Related Questions