0

In my form there is input fields and check boxes that repeat as below.

<form class="form-horizontal popupform" novalidate>
    <input type="text" data-ng-model="returns.altCity">
    <input type="text" data-ng-model="returns.altZip">
    <input type="text" data-ng-model="returns.altName">

 <table class="table table-striped">
       <thead>
        </thead>
        <tbody>
<tr data-ng-repeat="item in order_items">
         <td>{{item.id}}</td>
         <td>{{item.price}}</td>
        <td>
           <input name="quantity-item.id"  type="number"
                  data-ng-model="item.quantity"
                   value="returns.id">
         </td>
         <td align="center">
             <input type="checkbox" checklist-model="item.checkOrder"
                checklist-value="returns.id" checked="checked">
                  <label>&nbsp;</label>
</td>
            </tr>
                            </tbody>
                        </table>
 <button type="button" data-ng-click="saveReturnCases(returns)">Submit</button>

</form>

I want to get number input fields and check box values in button click. How can I get repeated field values?

1 Answer 1

1

You can store the values in an array, use the $index value increameted by ngRepeat, and then, submit this array ($scope.quantities and $scope.checksOrder).

<tr data-ng-repeat="returns in item.order_items">
         <td>{{item.id}}</td>
         <td>{{item.price}}</td>
        <td>
           <input name="quantity-item.id"  type="number"
                  data-ng-model="quantities[$index]"
                   value="returns.id">
         </td>
         <td align="center">
             <input type="checkbox" checklist-model="checksOrder[$index]"
                checklist-value="returns.id" checked="checked">
                  <label>&nbsp;</label>
</td>
            </tr>
                            </tbody>
                        </table>
 <button type="button" data-ng-click="saveReturnCases()">Submit</button>
Sign up to request clarification or add additional context in comments.

2 Comments

Hassein <input name="quantity-item.id" type="number" data-ng-model="item.quantity" value="returns.id"> here this field should show value that load from the ng-repert. In ` data-ng-model="quantities[$index]"` those value not show, this is a number field so user can change the loaded value and submit
I do not understant the first value is defined by the value attribute in the input, so, it is returns.id, maybe I do not get your point ?

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.