【发布时间】:2022-11-23 01:35:00
【问题描述】:
我想显示错误消息,例如最大输入限制所需的错误消息,但使用下面的代码它适用于 required 但不适用于 maxlength 。我也不使用 ts 文件。有什么办法可以做到这一点。谢谢
<form #featureForm="ngForm">
<mat-form-field class="featureInputForm" appearance="fill">
<mat-label>Feature Namre</mat-label>
<input matInput [(ngModel)]="featureName" required name="featureName" maxlength="64" (ngModelChange)="moduleNameChange($event)" />
<mat-error *ngIf="featureForm.controls['featureName']?.errors?.required">Feature Name is required.</mat-error>
<mat-error *ngIf="featureForm.controls['featureName']?.errors?.maxlength">Maximum limit exceed.</mat-error>
</mat-form-field>
</form>
【问题讨论】:
标签: javascript node.js angular validation angular-material