I'm using Angular reactive forms. On my page I need to optionally enable/disable fields (current password and new password + confirmation) so that I could use form.value
and get only those things I need (disabled controls won't be in there). However, I've found the approach of disabling FormControl
however, I need to disable whole group.
That's my group
formGroup: FormGroup = this.fb.group({
...
password: this.fb.group({
current: ['', Validators.required],
new: this.fb.group({
password: [{
value: '',
disabled: this.changePassword.value
}, Validators.required],
passwordConfirm: [{
value: '',
disabled: this.changePassword.value
}, Validators.required]
}, {validator: PasswordValidator.MatchPassword})
})
});
And this doesn't really work. How do I disable the whole password
FormGroup by attaching disabled state to standalone FormControl (checkbox).
.getRawValue
to understand why I need this – Sergey