基于反应形式答案选择的嵌套问题

时间:2019-03-27 17:12:54

标签: angularjs html5 angular-reactive-forms reactive-forms

我正在努力构建一个html模板和反应形式结构,以根据用户选择的答案显示动态问题。并记录用户选择的答案。我将首先收到如下所示的API响应(当前,我仅显示最小的一组值)。

具有

  1. mainCategoriesIdsList将用于匹配CategoriesList中的categoryId。
  2. categoriesList字段的initialFieldGroupIds将引用为
    fieldGroupList-> groupId只是一个问题。
  3. 在问题的fieldList-> fieldDataType中给出问题的类型。它可以显示文本区域,单选按钮,复选框,ETC
  4. fieldGroupList-> fieldListReferenceId包含有效值列表中答案的有效值参考ID。
  5. 如果用户选择的答案再次输入了dependentCategoryIds,将重复第一步

下面有JSON数据

{
  "mainCategoriesIdsList": [
    120,
    200
  ],
  "categoriesList": [
    {
      "categoryName": "Wealth",
      "categoryId": 120,
      "initialFieldGroupIds": [
        121
      ]
    },
    {
      "categoryName": "Health",
      "categoryId": 200,
      "initialFieldGroupIds": [
        121
      ]
    }
  ],
  "fieldGroupList": [
    {
      "groupId": 121,
      "groupLabel": "How have you accumulated most of your wealth?",
      "parentGroupId": 120,
      "fieldListReferenceId": [
        5000,7000
      ]
    }
  ],
  "fieldList": [
    {
      "fieldLabel": "Occupation",
      "fieldDataType": "MULTI_SELECT",
      "required": "Yes",
      "parentMetaDataId": 121
    }
  ],
  "validValuesList": [
    {
      "validValueRefId": 5000,
      "validValues": [
        {
          "valueId": 1008000,
          "valueLabel": "Employment",
          "valueDescription": "I earn/have earned income from an employer.",
          "valueSequence": 1,
          "dependantFieldGroupIds": [],
          "dependantCategoryIds": [
            200
          ]
        },
        {
          "valueId": 1008001,
          "valueLabel": "Self-Employment",
          "valueDescription": "I earn/have earned income from doing business as a sole proprietor or independent contractor and only generate income for myself.",
          "valueSequence": 2,
          "dependantFieldGroupIds": [],
          "dependantCategoryIds": []
        }
      ]
    }
  ]
}

用户选择的详细信息应保存如下

{
  "userInput": [
    {
      "date": "",
      "fieldId": "5000",
      "inputResponse": "",
      "valueIdList": [
        "1008000","1008001"
      ]
    }
  ]
}

0 个答案:

没有答案