这是我的FormGroup
subcomponents
})
我想在If条件中将此分支更新为必需的分支。我试图喜欢这个
repairFacilityForm = new FormGroup({
languageTypeId: new FormControl("", Validators.required),
repairFacilityId: new FormControl(""),
timeZone: new FormControl("", Validators.required),
name: new FormControl("", Validators.required),
address: new FormControl("", Validators.required),
branch: new FormControl(""),
}
但它无效
答案 0 :(得分:3)
您可以使用setValidators添加验证器
this.repairFacilityForm.controls["branch"].setValidators(Validators.required);
答案 1 :(得分:0)
尝试这样
languageTypeId: new FormControl("", [Validators.required]),
在数组块中添加验证