I come to you for talking about a problem with angular material. In fact, I think it\'s an issue, but I prefer looking for a misunterstanding first.
The first thing abou
obsessiveprogrammer's answer was correct for me, however I had to change the childrenEqual
function with angular 6 and strictNullChecks
(which is an option recommended by the angular team) to this:
static childrenEqual: ValidatorFn = (control: AbstractControl): ValidationErrors | null => {
const f = control as FormGroup;
const [firstControlName, ...otherControlNames] = Object.keys(f.controls || {});
if(f.get(firstControlName) == null) {
return null;
}
otherControlNames.forEach(controlName => {
if(f.get(controlName) == null) {
return null;
}
})
const isValid = otherControlNames.every(controlName => f.get(controlName)!.value === f.get(firstControlName)!.value);
return isValid ? null : { childrenNotEqual: true };
}