md-error with *ngIf having formcontrolsvalidation in md-input-container not working
See original GitHub issuemd-error with *ngIf not working whereas using md-error outside of md-input-container with *ngIf works as expected
Here is my code:
<form [formGroup]="searchForm" (ngSubmit)="onSubmit()" novalidate>
<md-input-container>
<input mdInput type="text" placeholder="First Name"
formControlName="firstName" >
</md-input-container>
<md-input-container>
<input mdInput type="text" placeholder="Middle Name"
formControlName="middleName">
<md-error *ngIf="!searchForm.value.firstName && !searchForm.pristine">
Please Enter Middle Name with First Name
</md-error>
</md-input-container>
<button md-raised-button> Search </button>
<button md-raised-button type="reset"> Clear </button>
</form>
How can I resolve this?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
md-error with *ngIf doesn't work #4027 - angular/components
<md-input-container> <input mdInput [(ngModel)]="sample" ... I have problems making Reactive form with FormGroup display md-error . md-hint ...
Read more >Angular : How to show md-error which is inside md-input ...
I want to show the 2nd md-error with the help of an event or any flag but not the value inside the ngModel...
Read more >Chapter 9: Forms - Angular in Action - liveBook · Manning
The form control has not been in focus. The MdError element is from the Material Design library and shows a little validation error...
Read more >Angular Forms and Validations
So we have to create our FormGroup like we explained above and create a FormControl to define our email form control with its...
Read more >Angular 2 / Material – md-error not displayed with custom validator ...
I am having some trouble getting validation errors to display on a model driven form with Angular (v4.3.6). In my model, I have...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@divyameher https://material.angular.io/components/input/overview#custom-error-matcher 😁
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.