You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:
Problem
I have this component:
functioninvalidTouched(control: AbstractControl|null|undefined): boolean{return!!(control?.invalid&&control.touched);}exportclassCustomErrorStateMatcherimplementsErrorStateMatcher{isErrorState(control: FormControl|null): boolean{returninvalidTouched(control)||invalidTouched(control?.parent);}}
@Component({changeDetection: ChangeDetectionStrategy.OnPush,selector: 'app-test',template: ` <form errorTailor [formGroup]="formGroup"> <!-- password field omitted for brevity --> <mat-form-field> <mat-label>Password confirmation</mat-label> <input matInput required formControlName="passwordConfirmation" type="password" [controlErrorAnchor]="passwordConfirmationControlErrorAnchor" [errorStateMatcher]="customErrorStateMatcher" /> <mat-error> <ng-template controlErrorAnchor #passwordConfirmationControlErrorAnchor="controlErrorAnchor" ></ng-template> <!-- Here I want to show passwordConfirmation OR formGroup errors, if passwordConfirmation has no errors. --> </mat-error> </mat-form-field> </form> `,})classTestComponent{readonlycustomErrorStateMatcher=newCustomErrorStateMatcher();readonlyformGroup=this.formBuilder.group({password: ['',[Validators.required]],passwordConfirmation: ['',[Validators.required]],},{validators: this.equalToValidator},);equalToValidator(group: FormGroup){constpassword=group.get('password').value;constpasswordConfirmation=group.get('passwordConfirmation').value;returnpassword===passwordConfirmation ? null : {equalTo: true}}}
... and the problem is that I need to show the equalTo error on the passwordConfirmationControlErrorAnchor template, but only if passwordConfirmation control itself has no error.
Is that possible?
Environment
Angular version: 11.0.0
The text was updated successfully, but these errors were encountered:
@NetanelBasal do the errorTailor works for html selecttextarea and radio-buttons tag as well ?
If yes, please let me know how to show the error-messages for the above types. (Btw I'm working on Angular 11, and Material modules for building reactive forms)
I'm submitting a...
Problem
I have this component:
... and the problem is that I need to show the
equalTo
error on thepasswordConfirmationControlErrorAnchor
template, but only ifpasswordConfirmation
control itself has no error.Is that possible?
Environment
The text was updated successfully, but these errors were encountered: