0

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 !

2
  • Code is not enough to figure out what you have in rowArray. Please post more code info. Commented Nov 21, 2017 at 9:53
  • What is "element name"? Please provide more code. What exactly is not working? Commented Nov 21, 2017 at 10:42

1 Answer 1

1

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>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.