How to get input value from dynamically created input box within a table using ng-repeat? I have this code in my html:
<table class="table table-striped" name="progressLogTable">
<thead>
<th>Title</th>
<th>Input</th>
</thead>
<tbody>
<tr ng-repeat="x in progressLog track by $index ">
<td>{{x}}</td>
<td><input type="number" ng-model="dataInput[$index]"></input></td>
</tr>
</tbody>
</table>
I need the value of what ever is inside of the text boxes generate when a button is clicked. Here is my JS so far:
$scope.gettingInputDataFromTrackables = function(){
$scope.dataInput =[];
}
I have tried dynamically creating the model of each input by using $index but I believe I am using it incorrectly. I have also tried having my td generated as:
<td>{{x}}</td>
<td><input type="number" ng-model="progressLog[$index]"></input></td>
but when I do that it binds my Title header to the value of the input box at that index. To summarize I just need the value of the input box that corresponds to the Title which is also dynamically added in the ng-repeat.
$scope.dataInputwhen you press the submit button? How is it not working?console.log($scope.dataInput);inside the submit function it logs an empty array as apposed to the values of the dynamically created input boxes.ng-model="x.dataInput". Alsotrack by $indexgets so quirky once you want to add/remove any items. It will save you tons of trouble to just make sure your items in progressLog-items has a proper id field with unique values and dong-repeat="x in progressLog track by x.id". Again, not what you was asking- sorry!