Angular 2: Iterate over reactive form controls

前端 未结 9 751
遥遥无期
遥遥无期 2020-12-02 07:23

I would like to markAsDirty all the controls inside of a FormGroup.

9条回答
  •  失恋的感觉
    2020-12-02 07:32

    I create this function to make it* I have a control with name 'order', and pass index to him.

    {"conditionGroups": [
       {
         "order": null,
         "conditions": []
       }
      ]
    }
    
    
    updateFormData() {
        const control = this.form.controls['conditionGroups'];  
        control.value.map((x,index)=>{
        x.order = index; 
     })
    

提交回复
热议问题