I need assistance with setting the ng-model
for answer option checkboxes in a list of questions and options. I am currently using two ng-repeat
directives to display the questions and options, but I'm unsure how to set the ng-model
to capture all selected options for each question.
My attempt at setting the ng-model
as answers[qst.id][ans.id]
resulted in an error:
TypeError: Cannot set property '*' of undefined
<div ng-repeat="qst in questions">
<div>{{qst.question}}</div>
<div>
<ul>
<li ng-repeat="ans in answers">
<span>
<input type="checkbox" ng-model="answers[qst.id][ans.id]">
</span>
<span>
{{ans.ansOption}}
</span>
</li>
</ul>
</div>
</div>
Can someone provide guidance on the correct approach to achieve this?