私はAngularが初めてで、次のようにng-repeat内にネストされたng-repeatがあるという問題に悩まされていました。
<div ng-repeat="question in main.questions">
<div class="row">
<br/><span>Q{{$index+1}}. {{question.Ques.questiontxt}}</span>
</div>
<div ng-repeat="answer in question.Answer">
<input type="radio" name="question{{$parent.$index}}" value="{{answer.answertxt}}{{$parent.$index}}"/> {{answer.answertxt}}
</div>
</div>
ここで、main.questions は質問の配列です。各質問には、2 番目の ng-repeat ブロックで反復される複数のオプションがあります。ただし、次のようにラジオボタン入力に ng-model を使用しようとすると:
<input type="radio" name="question{{$parent.$index}}" value="{{answer.answertxt}}{{$parent.$index}}" ng-model="main.formData"/> {{answer.answertxt}}
、組み合わせたすべての質問に対して 1 つのオプションしか選択できません (理想的には、質問ごとに 1 つのオプションを選択できる必要があります)。また、ng-model を使用しない場合、質問ごとに 1 つのオプションを選択できますが (そうあるべきです)、選択した入力の値を取得できません。
ここで何が問題になるのか教えてください。私がここでやろうとしていることを達成するためのより良い方法はありますか? 選択した各オプションの値をキャプチャして、JSON オブジェクトに追加する必要があります。