I am trying to pass value quest.quesId and questionOption.name to function checkScore. But it is coming as undefined(questionId, optionName). If same line is put inside ol then I am able to get the quest.quesId but this would not suffice the purpose.
HTML page
<ol>
<li ng-repeat="quest in questionJson" value={{quest.quesId}}>
{{ quest.question }}
<div>
<label ng-repeat="questionOption in optionJson" ng-if="questionOption.quesId == quest.quesId">
<input type= "radio" value = "{{ questionOption.name }}" name="radio{{questionOption.quesId}}">
{{ questionOption.option }}
</label>
</div>
</div>
</li>
</ol>
<button type="submit" ng-click="checkScore(quest.quesId, questionOption.name)"> Check Score </button>
JS page var qnaModule = angular.module("qnaModule", []);
qnaModule.controller("qaCtrl", function($scope) {
$scope.questionJson = [{
"question": "What's your name?",
"quesId": 1
}, {
"question": "When was the universe form?",
"quesId": 2
}]
$scope.optionJson = [{
"option": "A",
"quesId": 1
}, {
"option": "B",
"quesId": 1
}, {
"option": "C",
"quesId": 1
}, {
"option": "D",
"quesId": 1
}, {
"option": "ABC",
"quesId": 2
}, {
"option": "XYX",
"quesId": 2
}, {
"option": "XYZ",
"quesId": 2
}, {
"option": "PQRS",
"quesId": 2
}]
var answerJson = $scope.answerJson = [{
"quesId": 1,
"answer": "A"
}, {
"quesId": 2,
"answer": "XYZ"
}]
$scope.checkScore = function(questionId, optionName) {
console.log(questionId);
console.log(optionName);
}
});
