Friday, January 22, 2021

Angular Material Help Required

Hi, 

I was hoping someone could help me with this. I know this is not angular group :P 

Requirement: errors should be displayed just after the mat-label. 

Problem: mat-error is always displayed below the matInput in angular material theme. It doesnt matter in which order I write the markup, errors are always displayed below the input. 

Solution: 
1. mat-errors need to be made inline in the css, I found the css code that will make this change. 
2. mat-error are always subscripted to matInput - I need help with this. 
I want to understand how this happens in the framework and how to stop this default behaviour. 
I have looked into the source code, but could not find the code responsible for this.

This change needs to be done project wide. Please suggest a solution that's ideal. 
One solution would be to extend the default angular/material directives and make the changes in those and import extended directives instead of the default directives.
Is there a better way to do this?

Thanks in advance! 


My code in theme pages
<mat-form-field>
<mat-label>First name </mat-label>
<mat-error *ngIf="signUpForm.get('first_name').hasError('required')"> is required </mat-error>
<input id="name" matInput [formControlName]="'first_name'" />
</mat-form-field>


I think below code is the markup of errors
<div class="mat-form-field-subscript-wrapper" [ngSwitch]="_getDisplayedMessages()">
<div *ngSwitchCase="'error'" [@transitionMessages]="_subscriptAnimationState">
<ng-content select="mat-error"></ng-content>
</div>
...
</div>



Regards,
Chetan Ganji
+91-900-483-4183

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMKMUjuTntpDGPHNsTSUvMNN2b%2BdbYS-4WW12E9ZTrnaOiMYPw%40mail.gmail.com.

No comments:

Post a Comment