AngularJS directive for unique email address

AngularJS directive for unique email address.

 

Refs:
https://www.ng-newsletter.com/posts/validations.html
https://blog.brunoscopelliti.com/form-validation-the-angularjs-way

Sam Deering

Sam Deering

Sam is a web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and sharing what he learns with others.

2 thoughts on “AngularJS directive for unique email address

  1. One problem with this code.
    If it will set model validity to false (ctrl.$setValidity(‘unique’, data.status);)
    it will never again pass the condition:
    if (scope.registerForm.email.$valid) {
    email model will be always $invalid due to ‘unique’ and so the form will be always $invalid. IMHO the better would be condition:
    if (!scope.registerForm.email.$error.required && !scope.registerForm.email.$error.email)

Leave a Reply

Your email address will not be published. Required fields are marked *