I have an object named studentData which has a number of attributes. I have a table corresponding to a certain number of questions. What I intend to do is, for each student, check the value of question number which is correct and push into studentData.correctQuestionNumbers which is an array.
However, the checkboxes don't seem to repeat.
View:
<table class="flat-table flat-table-3">
<tr>
<th>Student Name</th>
<th ng-repeat="questionNumber in questionNumbers">{{ questionNumber }}</th>
</tr>
<tr ng-repeat="student in studentData">
<td>{{ student.name }}</td>
<td ng-repeat="questionNumber in questionNumbers"><input type="checkbox" ng-model="student.correctQuestionNumbers[]"></td>
</tr>
</table>
Controller:
$scope.questionNumbers = [1, 2, 3, 4, 5]
$scope.correctQuestionNumbers = [];
$scope.selectStudents = [{batch:'A1', name: 'ABC'}, {batch:'A2', name: 'XYZ'}];
$scope.studentData = [];
for(var i = 0; i < $scope.selectedStudents.length; i++){
$scope.studentData.push({name: $scope.selectedStudents[i].name,
batch: $scope.selectedStudents[i].batch,
correctQuestionNumbers: $scope.correctQuestionNumbers});
}