Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(input): add directive for displaying error messages#3560
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
42dab5ec7e2d69a9d144a6706708dcd029a3a829903744a13File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,6 +51,51 @@ | ||
| </md-card-content> | ||
| </md-card> | ||
| <md-card class="demo-card demo-basic"> | ||
| <md-toolbar color="primary">Error messages</md-toolbar> | ||
| <md-card-content> | ||
| <h4>Regular</h4> | ||
| <p> | ||
| <md-input-container> | ||
| <input mdInput placeholder="example" [(ngModel)]="errorMessageExample1" required> | ||
| <md-error>This field is required</md-error> | ||
| </md-input-container> | ||
| <md-input-container> | ||
| <input mdInput placeholder="email" [formControl]="emailFormControl"> | ||
| <md-error *ngIf="emailFormControl.hasError('required')"> | ||
| This field is required | ||
| </md-error> | ||
| <md-error *ngIf="emailFormControl.hasError('pattern')"> | ||
| Please enter a valid email address | ||
| </md-error> | ||
| </md-input-container> | ||
| </p> | ||
| <h4>With hint</h4> | ||
| <md-input-container> | ||
| <input mdInput placeholder="example" [(ngModel)]="errorMessageExample2" required> | ||
| <md-error>This field is required</md-error> | ||
| <md-hint>Please type something here</md-hint> | ||
| </md-input-container> | ||
| <form novalidate> | ||
| <h4>Inside a form</h4> | ||
| <md-input-container> | ||
| <input mdInput name="example" placeholder="example" | ||
| [(ngModel)]="errorMessageExample3" required> | ||
| <md-error>This field is required</md-error> | ||
| </md-input-container> | ||
| <button color="primary" md-raised-button>Submit</button> | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this button supposed to do something? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's used to test out that form submission shows the error messages. | ||
| </form> | ||
| </md-card-content> | ||
| </md-card> | ||
| <md-card class="demo-card demo-basic"> | ||
| <md-toolbar color="primary">Prefix + Suffix</md-toolbar> | ||
| <md-card-content> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the error animation is kind of strange in this case, the error message seems to appear in the middle of the input and then move down (I think because the message wraps on to 2 lines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take another look. It probably needs a
transform-origin.