Dynamic nested form controls Angular 2

Viewed 860

my API response is like

"groups": [{
          "group_name": "GRP1"
          "attributes": [{
                        "attribute_id": 1,
                        "attribute_name": "Frequency",
                        "value_reference": "tag"
                        }]
          },
          {
            "group_name": "GRP2"
           "attributes": [{
                        "attribute_id": 2,
                       "attribute_name": "Date",
                        "value_reference": "static",
                        "value_static_type": "date"
                      }]
              }]  

-- How I can create formConrol in Angular 4 to display data like

GroupName  
   List of Group's Attribute  
GroupName
    List of Group's Attribute  

My initial form control is like

this.editTemplateForm = this.fb.group({
            groups: this.fb.group({
                group_name: ['', Validators.required ],
                attributes : this.fb.group({
                    value_reference : []
                })
            }),
        });  

I don't understand how add control dynamically

1 Answers
Related