我正在使用Angular反应形式 . 在我的页面上,我需要选择启用/禁用字段(当前密码和新密码确认),以便我可以使用 form.value
并仅获取我需要的东西(禁用控件赢得't be in there). However, I'已找到禁用 FormControl
的方法但是,我需要禁用整个团体 .
那是我的小组
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})
})
});
这并没有真正起作用 . 如何通过将禁用状态附加到独立FormControl(复选框)来禁用整个 password
FormGroup .
2 回答
你可以在
form
标签内打开fieldset
标签,并根据表格控制值使用disable
指令解决了