I\'m looking at adding some basic email validation to check that the user has put in a correct email address. Currently using the method below, the validation updates as the
Found a way, in rc6.
1- Create a directive: validate-onblur.directive.ts
@Directive({
selector: '[validate-onblur]',
host: {
'(focus)': 'onFocus($event)',
'(blur)': 'onBlur($event)'
}
})
export class ValidateOnBlurDirective {
constructor(public formControl: NgControl) {
}
onFocus($event) {
this.formControl.control.markAsUntouched(false);
}
onBlur($event) {
this.formControl.control.markAsTouched(true);
}
}
Then in your html template just add the directive to your form, my example use the ReactiveFormsModule model.
Then add this to your error message:
...