我有这个反应性的 Angular Form 结构:
myForm: FormGroup;
Personal: FormGroup;
FIRST_NAME: FormControl;
LAST_NAME: FormControl;
ngOnInit(): void {
this.createFormControls();
this.createForm();
}
createFormControls() {
this.FIRST_NAME = new FormControl('', [Validators.required]);
this.LAST_NAME = new FormControl('', [Validators.required]);
}
createForm(): void {
this.myForm = this.fb.group({
Personal: this.fb.group({
FIRST_NAME: this.FIRST_NAME,
LAST_NAME: this.LAST_NAME,
})
})
}
如果我做:
this.FIRST_NAME.disable();
它禁用 FormControl。
如何禁用Personal
FormGroup中的所有 FormControl