I am currently facing an issue with updating subquestions for each question in the code below. Despite my efforts, the subquestions do not update properly and I end up with the same subquestion list for all questions.
How can I display each question along with its corresponding list of subquestions?
function loadAllQuestionGroup () {
Questiongroup.query({}).$promise.then(function(group){
vm.questiongroups = group;
for(var i=0;i<group.length;i++){
var grouptitle=group[i].title
Question.questionsByQuestionGroup({id:group[i].id}).$promise.then(function(question){
vm.question = question;
for(var j=0;j<question.length;j++){
Subquestion.subquestionsByQuestion({id:question[j].id}).$promise.then(function(subquestion){
vm.subquestions=subquestion;
});
}
});
}
});
}
<div ng-repeat="question in vm.question">
{{question.name}}
<div ng-repeat="subquestion in vm.subquestions">
{{subquestion.name}}
</div>
</div>