我正在尝试根据服务器响应创建动态表单。例如,我有 8 个按钮,每个按钮在单击时应生成具有不同输入类型的不同问卷。每个类别的问题都是从后端获取的,每个问题都有其类型,可以是单选、选择等。根据这些信息,我如何根据用户的按钮为特定问题集生成表单点击。我想到的一件事是根据单击的类别使用 ng-hide/show,但这将是一个非常糟糕的做法,因为 8 个类别(每个类别 8 个)总共有 64 个问题。任何帮助,将不胜感激。谢谢!!
响应如下:
{
"code": 200,
"data": {
"id": "598ca3dac405bc378fc21764",
"question_set_number": "QS1",
"questions": [
{
"answers": [
"Answer 1",
"Answer 2",
"Answer 3"
],
"id": "59839d20c405bc411540a11d",
"question_number": "Q1",
"question_text": "Test question",
"type": "radio"
},
{
"answers": [
"Answer 1",
"Answer 2",
"Answer 3"
],
"id": "59839d2dc405bc411540a11e",
"question_number": "Q2",
"question_text": "Test question",
"type": "check"
}
]
},
"message": "successful",
"status": "success"
}