Angularjs no of input fields based on select value

  angularjs, html-select, html-table, javascript

I am trying to generate a dynamic input list based on the selection from the select tag. Ultimately what I want to do is to display something like this

enter image description here

I am trying the following

<b>Num Repititions: </b><select ng-model="noOfReps" name="rep" id="rep">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select></label><br />
<label><b>Heading 1: </b>
<input type="text" size="4" ></label><br />
<label><b>Heading 2: </b></label><br />
<label><b>Heading 3: </b></label><br />

and I also have

    $scope.noOfReps = 2;

So the first issue i’m seeing is that even though I set the scope variable here, I don’t see the select value being populated as 2.

The other thing is, i’m not sure whats the best approach to get the repeatable input elements inside the screenshot. If I have to use an ng-repeat, do I use it on an input or have a li tag with an ng-repeat and just have the input with an ng-model bound to it.

Source: AngularJS Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.