Комментарии:
Thanks for this! Just a note to build on your effort here. If you want to pass parameters to your custom validator function you can do it like so:
import { AbstractControl, ControlContainer, ValidationErrors, ValidatorFn } from "@angular/forms";
export function checkvaluesmatch(val1: any, val2: any): ValidatorFn {
return (control: AbstractControl): ValidationErrors | null => {
let v1 = control.get(val1);
let v2 = control.get(val2);
if (v1 && v2 && v1?.value != v2?.value) {
return {
valuematcherror: true
}
}
return null;
}
}
This way you are not tied to using the key words 'password' and 'confirmpassword'. This is a more abstract approach. Then just call it like..
....{ validators: checkvaluesmatch('password', 'confirmpassword') });
thanks for the video but mat-error doesnt work with this validations
ОтветитьThat's great! Thank you so much for the tutorial. Short and beautiful!
Ответитьthank you very much
ОтветитьThank you very much! you've been incredibly helpful to me!
ОтветитьAwesome, thanks!
Ответитьniceeee thanks so much
ОтветитьHi @dhanjay kumar, recently wateched your very nice, my one suggestion is, am a begginer to start angular , can you re- arrange the begginer level & intermediate level in your playlist, and also you created batch 4 in playlist it's okay with start that beginner level
ОтветитьNice
Ответить