Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular Material Hints and Error Messages for Value Components #31

Open
mdelez opened this issue Feb 20, 2020 · 1 comment
Open

Angular Material Hints and Error Messages for Value Components #31

mdelez opened this issue Feb 20, 2020 · 1 comment
Assignees

Comments

@mdelez
Copy link
Contributor

mdelez commented Feb 20, 2020

Integrate mat-hint and mat-error in the form control

@tobiasschweizer
Copy link
Contributor

example how to show validator specific messages:

<span [formGroup]="form">
    <mat-form-field class="large-field">
        <input matInput [formControlName]="'intValue'" class="value" placeholder="Int value" type="number" [readonly]="mode === 'read'" [errorStateMatcher]="matcher">
        <mat-hint>integer</mat-hint>
        <mat-error *ngIf="valueFormControl.hasError('required')">
          A value is required
        </mat-error>
        <mat-error *ngIf="valueFormControl.hasError('valueNotChanged')">
          Please change value
        </mat-error>
        <mat-error *ngIf="valueFormControl.hasError('pattern')">
          Please enter a valid integer
        </mat-error>
    </mat-form-field>
    <mat-form-field class="large-field">
        <input matInput [formControlName]="'comment'" class="comment" placeholder="Comment" type="text" [readonly]="mode === 'read'">
    </mat-form-field>
</span>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants