【发布时间】:2021-01-08 03:13:27
【问题描述】:
如果用户在提交表单时没有选择任何选项,我想在 mat-radio-group 上添加验证。这是我到目前为止所做的,但它不起作用。
<mat-radio-group formControlName="{{e.Index}}">
<mat-label>{{ et.Title }}</mat-label>
<mat-radio-button *ngFor="let tq of e.Items" [value]="tq" [checked]="tq.IsSelected">
{{tq.Name}}
</mat-radio-button>
</mat-radio-group>
TS
elements.forEach((e, i) => {
case form.id: {
if (e.Required) {
a = { [name]: new FormControl('', Validators.required) };
} else {
a = { [name]: new FormControl('') };
}
etc ...
break;
}
}
【问题讨论】:
标签: angular angular-reactive-forms