下面的角度是前面用于文本框验证的代码:
<input class="form-control" type="text" name="name" aria-label="{{name}}" data-ng-minlength="1" data-ng-maxlength="100" data-ng-pattern="displayNamePattern" required />
this.lengthValidationMessage = function (minLength, maxLength) {
return resx('Localization.Validation_FieldLength').replace("{0}", minLength).replace("{1}", maxLength);
};
角度4:
<input type="text" class="form-control" id="title" name="title"
[(ngModel)]="title" #Title="ngModel" required minlength="1" maxlength="255"> <div *ngIf="Title.invalid && Title.dirty && Title.touched" class="alert-error">
{{'Validation_FieldLength' | resourcePipe}}
如何在角度4中使用以上功能在UI中显示错误消息。 在UI中从本地化字符串中获得了此字符串。该字符串必须介于{0}和{1}个字符之间。