Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I have some form_elements which I use for ng-repeat, I have some question.fields which holds all fields for the nested loop.

For the binding of the form element (and the submission to the backend) I use a pregenerated array with objects:

review.values = []
obj = {};
obj['qid'] = question_id
obj['field_type'] = field_type
obj['val'] = ""
review.values.push(obj)

<div ng-repeat="element in form_elements">
    <div ng-repeat="field in element.question.fields">
            <label><input type="radio" ng-model="review.values[$parent.$index*review.values.length].val" value="someval"> MyLabel</label>
    </div>
</div>

I don't know how to bind the correct review.values[xyz].val entry in the second loop? review values is finally the array that gets saved. I tried already with an helper function, that gets for me the right entry of review.values with the question_id without success.

Thanks, for any help.

Patrick

share|improve this question
    
Setup a plunker ans will be faster to help you – dimirc Jan 28 '14 at 22:25
    
What are you trying to do with the $parent.$index? If you want to find the position of your object in review.values, you should use an object that maps your form_elements and your fields to your review values instead of a list. – dtheodor Jan 28 '14 at 22:33
    
$parent.index was only a thought to calculate the position of the object, there are several objects in the review.values array? or how do you mean? – Patrick Winkler Jan 29 '14 at 14:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.