在嵌套的ng-repeat中仅选择一个单选按钮值。 能否请您在源代码中提出错误
<form ng-submit="save()">
<div ng-repeat="x in surveyLst">
<div class="row">
<br/>
<span>{{$index+1}} . {{x.question}}</span>
</div>
<div ng-repeat="src in x.optnLst track by $index" ng-init='test=$index'>
<input type="radio" name={{$parent.$index+1}} ng-model="data.selectedOption" ng-value="x.optnLst[test]" />
{{x.optnLst[test]}}
</div>
</div>
{{data}}
<input type="submit" value="Submit">
</form>
答案 0 :(得分:0)
而不是在data.seletedOption
中使用ng-model
将其设置为x.seletedOption
<input type="radio" name={{$parent.$index+1}} ng-model="x.selectedOption" ng-value="x.optnLst[test]" />