我使用angularjs创建测验应用程序并遇到一些问题 当我点击“下一步”时,选中的收音机不会重置
<div ng-repeat="answ in quiz.typical">
<label ng-click="quiz.checkAnsw()">
<input type="radio" name="answ{{quiz.qNum}}">
{{answ.text}}
</label>
</div>
Fiddle
如何重置检查无线电?
答案 0 :(得分:2)
您可以为收音机设置值,然后通过ng-model
<div ng-repeat="answ in quiz.typical">
<label ng-click="quiz.checkAnsw()">
<input type="radio" name="answ{{quiz.qNum}}" ng-value="$index" ng-model="quiz.selectedAns" />
{{answ.text}}
</label>
</div>
并在控制器中,将quiz.selectedAns
重置为undefined
:
this.changeQ = function(){
this.qNum++;
this.selectedAns = undefined;
};
JSFiddle: http://jsfiddle.net/zug5y/