Description
Bug, feature request, or proposal:
I tried to compare the value of two fields in the form, but it doesn't work with mat-error.
When i set a password, i want to display two error messages under the two input component or display at least the error message under the empty component.
Here is one of the input component, another one is coded with the same code.
HTML:
*****
<mat-error *ngIf="form.errors.mismatch">
mismatch error
TYPESCRIPT:
const form = new FormGroup({
password: new FormControl('', Validators.minLength(2)),
passwordConfirm: new FormControl('', Validators.minLength(2)),
}, passwordMatchValidator);
function passwordMatchValidator(g: FormGroup) {
return g.get('password').value === g.get('passwordConfirm').value
? null : {'mismatch': true};
}
What is the expected behavior?
I want to display the error after the input
What is the current behavior?
No error displayed
What are the steps to reproduce?
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
What is the use-case or motivation for changing an existing behavior?
I want to compare the password, and display the error message after each input component
It works when i use the <div *ngIf="hasError()"> to dislpay the error message, but not with mat-error.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular V5.0.3
Material: V5.0.0-rc.1