angular - how to push new control inside of FormArray which is already inside another FormArray? -


i working on angular 4 application , using reactive forms. getting 1 issue while creating new form control.

typescript:

couponform : formgroup; "industries": [             {                 "id": 1,                 "name": "home cleaning",                 "is_active": true,                 "forms": [                 {                     "id": 1,                     "name": "form 1",                 }             },             {                 "id": 2,                 "name": "office cleaning",                 "is_active": true,                 "forms": [                 {                     "id": 2,                     "name": "form 2",                  }             } ];  constructor(private formbuilder: formbuilder) {    this.couponform = this.formbuilder.group({}); }  addindustriescontrol() {    this.couponform.addcontrol('applicable_with_industries', this.formbuilder.array([]));     let industriesarray =  <formarray>this.couponform.controls['applicable_with_industries'];     this.globalsettings.industries.foreach((industry, index) =>{       let control = this.formbuilder.group({          industry_id   : [industry.id],          status        : [],          forms         : this.formbuilder.array([])       });        industriesarray.push(control);   });       } 

i want add new controls in forms array inside each industry. can 1 please tell me how can it?

let array = (this.couponform.controls['applicable_with_industries']).controls[index].get('forms');


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -