Skip to content

Commit

Permalink
fix(demo): issue when opening ngx-form-error page in demo apps
Browse files Browse the repository at this point in the history
When opening ngx-form-error page this raise an jasvscript error.

ISSUES CLOSED: NationalBankBelgium#43
  • Loading branch information
mhenkens committed Oct 12, 2023
1 parent 0e9cca2 commit 9c5e166
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1 class="mat-display-1">Reactive Forms with NgxFormErrors</h1>
/>
<mat-error>
<ng-template
ngxFormErrors="matchingPasswords.password"
ngxFormErrors="password"
ngxFormErrorsFieldName="DEMO.FIELDS.PASSWORD_ALIAS"
#passwordField="ngxFormErrors"
></ng-template>
Expand All @@ -40,10 +40,7 @@ <h1 class="mat-display-1">Reactive Forms with NgxFormErrors</h1>
required
/>
<mat-error>
<ng-template
ngxFormErrors="matchingPasswords.confirmPassword"
#confirmPasswordField="ngxFormErrors"
></ng-template>
<ng-template ngxFormErrors="confirmPassword" #confirmPasswordField="ngxFormErrors"></ng-template>
</mat-error>
</mat-form-field>
</div>
Expand Down
4 changes: 2 additions & 2 deletions demo-app/ng7/src/app/parent-error-state-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { FormControl, FormGroupDirective, NgForm } from "@angular/forms";
export class ParentErrorStateMatcher implements ErrorStateMatcher {
public isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted: boolean = !!(form && form.submitted);
const formGroupValid: boolean = !!(form && form.valid);
const formGroupInvalid: boolean = !!(form && form.invalid);

return !!((control && control.invalid && (control.dirty || control.touched)) || isSubmitted || formGroupValid);
return !!(control && (control.invalid || formGroupInvalid) && (control.dirty || control.touched || isSubmitted));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1 class="mat-display-1">Reactive Forms with NgxFormErrors</h1>
/>
<mat-error>
<ng-template
ngxFormErrors="matchingPasswords.password"
ngxFormErrors="password"
ngxFormErrorsFieldName="DEMO.FIELDS.PASSWORD_ALIAS"
#passwordField="ngxFormErrors"
></ng-template>
Expand All @@ -40,10 +40,7 @@ <h1 class="mat-display-1">Reactive Forms with NgxFormErrors</h1>
required
/>
<mat-error>
<ng-template
ngxFormErrors="matchingPasswords.confirmPassword"
#confirmPasswordField="ngxFormErrors"
></ng-template>
<ng-template ngxFormErrors="confirmPassword" #confirmPasswordField="ngxFormErrors"></ng-template>
</mat-error>
</mat-form-field>
</div>
Expand Down
4 changes: 2 additions & 2 deletions demo-app/ng8/src/app/parent-error-state-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { FormControl, FormGroupDirective, NgForm } from "@angular/forms";
export class ParentErrorStateMatcher implements ErrorStateMatcher {
public isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
const isSubmitted: boolean = !!(form && form.submitted);
const formGroupValid: boolean = !!(form && form.valid);
const formGroupInvalid: boolean = !!(form && form.invalid);

return !!((control && control.invalid && (control.dirty || control.touched)) || isSubmitted || formGroupValid);
return !!(control && (control.invalid || formGroupInvalid) && (control.dirty || control.touched || isSubmitted));
}
}

0 comments on commit 9c5e166

Please sign in to comment.