我正在为我的大学项目创建一个小应用程序,我有一个场景,当用户点击一个单选按钮时,应该触发一个事件.
我的Angular代码块:
<div ng-repeat="q in questionList " ng-if="ExamOver == false">
<h2>{{count+1}} .{{q.questionText}}</h2>
<ul>
<li ng-repeat="d in q.Choices">
<input type="radio" name="isCorrect" ng-model="correctAnswer.isworking" ng-change="getDetails($index,d,correctAnswer.isCorrect);" value="Yes" />
{{d.choiceText}}
</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我有这个代码:
$scope.correctAnswer = {isCorrect : false};
$scope.getDetails = function (index, choiceList, isCorrect) {
/* some logic... */
}
Run Code Online (Sandbox Code Playgroud)
事件每个按钮只发射一次,我试图解决这个过去几个小时没有任何进展,有人可以指导我在这里做错了吗?