I have a reactive form in my component, and I want to set the touched property for each of the inputs to true . My current code does this, but throws a Cannot set property touched of #<AbstractControl> which has only a getter error:
addressForm: FormGroup; ... this.addressForm = this._fb.group({ street: ["", [<any>Validators.required]], city: ["", [<any>Validators.required]], state: ["", [<any>Validators.required]], zipCode: ["", [<any>Validators.required]], country: ["", [<any>Validators.required]] }); ... for (var key in this.addressForm.controls) { this.addressForm.controls[key].touched = true; }
How can I set the touched value of each contribution to true ?
source share