Angular 2: Iterate over reactive form controls

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

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

9条回答
  •  攒了一身酷
    2020-12-02 07:33

    Seems that get function is not working anymore for retrieving specific values in your form in Angular 8, so this is how I solved it based on the answer of @Liviu Ilea.

    for (const field in this.myForm.controls) { // 'field' is a string
      console.log(this.myForm.controls[field].value);
    }
    

提交回复
热议问题