Skip to content

Instantly share code, notes, and snippets.

@xiongemi
Created May 19, 2020 06:59
Show Gist options
  • Save xiongemi/bf5c2fd4062d79e9e714ba4ad4c72ec9 to your computer and use it in GitHub Desktop.
Save xiongemi/bf5c2fd4062d79e9e714ba4ad4c72ec9 to your computer and use it in GitHub Desktop.
update errorStateMatcher in html
<mat-form-field class="mr3">
<mat-label>
{{ 'DELIVERY.PASSWORD' | translate }}
<span aria-hidden="true"> * </span>
</mat-label>
<input type="password" matInput formControlName="password" [errorStateMatcher]="passwordErrorStateMatcher" maxlength="30" />
<mat-error *ngIf="deliveryPageForm.hasError('password')">
{{ 'ERRORS.REQUIRED' | translate }}
</mat-error>
<mat-error *ngIf="deliveryPageForm.get(['account', 'password']).hasError('pattern')">
{{ 'ERRORS.PATTERN' | translate }}
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>
{{ 'DELIVERY.CONFIRM_PASSWORD' | translate }}
<span aria-hidden="true"> * </span>
</mat-label>
<input
type="password"
matInput
formControlName="confirmPassword"
[errorStateMatcher]="confirmPassowrdErrorStateMatcher"
maxlength="30"
/>
<mat-error *ngIf="deliveryPageForm.hasError('confirmPassword')">
{{ 'ERRORS.REQUIRED' | translate }}
</mat-error>
<mat-error *ngIf="deliveryPageForm.hasError('passwordMatch')">
{{ 'DELIVERY.PASSWORD_MATCH' | translate }}
</mat-error>
</mat-form-field>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment