我想在angualar5项目反应形式中的formArry中迭代formArray, 我尝试保留两个fromArray,parent(initSection)和child(initQuestion),请参考以下工作网址: https://stackblitz.com/edit/deep-nested-reactive-form-1p9mza?file=app/app.component.ts
在每个用户3个问题的子数组中,有人可以建议如何迭代我的父数组或两个用户项吗?以及如何在提交时映射与问题对应的所选单选按钮值?
UI设计如下所示
下面是我的输入
this.userList = [
{
"name": "sam",
"questionsList":[
{
"question": "question 0111111?"
},
{
"question": "question 0222222?"
},
{
"question": "question 03333333?"
}
]
},
{
"name": "robert",
"questionsList":[
{
"question": "question 0111111?"
},
{
"question": "question 0222222?"
},
{
"question": "question 03333333?"
}
]
}
]
当用户提交我的表单时,我希望输出如下所示:
userList: [
{
"name": "sam",
"questionsList":[
{
"question": "question 0111111?",
"isSelected": "yes"
}
{
"question": "question 0222222?",
"isSelected": "no"
}
{
"question": "question 03333333?",
"isSelected": "yes"
}
]
},
{
"name": "robert",
"questionsList":[
{
"question": "question 0111111?",
"isSelected": "no"
}
{
"question": "question 0222222?",
"isSelected": "yes"
}
{
"question": "question 03333333?",
"isSelected": "no"
}
]
}
]