验证仅将输入文本涂成红色,但似乎未显示在nz-form-control
控件中设置的nzErrorTip消息。
请参见下面的代码:
<form nz-form [formGroup]="myForm" (ngSubmit)="submitHandler()">
<nz-form-item>
<nz-form-label [nzSpan]="5" nzRequired nzFor="Name">Name</nz-form-label>
<nz-form-control [nzSpan]="8" nzErrorTip="Please input your name">
<input type="text" nz-input formControlName="Name" placeholder="Please input your name" />
</nz-form-control>
</nz-form-item>
<button color="primary" type="submit">Submit Form</button>
</form>
不显示在nzErrorTip
中设置的验证消息
async submitHandler() {
for (const i in this.myForm.controls) {
this.myForm.controls[i].markAsDirty();
this.myForm.controls[i].updateValueAndValidity();
}
this.loading = true;
const formValue = this.myForm.value;
try {
} catch (err) {
console.error(err);
}
this.loading = false;
}
预期结果将显示nzErrorTip中所述的消息,如documentation
中所述答案 0 :(得分:0)
您应该将ant-zorro更新到8.0版!
当它是7.5x时,就像这样
<nz-form-explain *ngIf="validateForm.get('email')?.dirty && validateForm.get('email')?.errors">
The input is not valid E-mail!
</nz-form-explain>