【发布时间】:2019-06-26 18:58:25
【问题描述】:
-
我正在使用嵌套的 FormGroup,并且在 html 中 FormGroup 是父级 formGroup 和技能是嵌套表单,但在验证控件上是 没有找到。任何人都可以帮助解决这个问题。提前致谢。
ngOnInit() { this.studentForm = new FormGroup({ fullName: new FormControl('', Validators.required), email: new FormControl('', [Validators.required, Validators.email]), skills: new FormGroup({ skillName: new FormControl(), ExperienceInYears: new FormControl(), Proficiency: new FormControl() }) }) html --- <div formGroupName='skills'> <div class="form-group"> <label for="Email1">Skill Name</label> <input type="text" class="form-control" formControlName='skillName' placeholder="Skill Name"> <div *ngIf="studentForm.controls['skills'].controls[skillName].invalid && (studentForm.controls['skills'].controls[skillName].dirty ||studentForm.controls['skills'].controls[skillName].touched)" class="警报警报-危险"> 技能名称是必需的。
validation is not working ERROR TypeError: Cannot read property 'invalid' of undefined can any one help
【问题讨论】:
-
感谢您的回答,错误已解决,但嵌套的 FormGroup 验证不起作用
标签: angular