Skip to content

Form Validation #2

Description

@r0610205

Directive works perfect on submit, however it doesn't work with form validations. Especially if 'submit' button disabled until form is valid. What do you think about updating model at the time directive compiled with a small timeout like this:

link: function(scope, elem, attrs, ngModel) {
    var origVal = elem.val();
    $timeout(function () {
          var newVal = elem.val();
          if(ngModel.$pristine && origVal !== newVal) {
              ngModel.$setViewValue(newVal);
          }
    }, 500);
    scope.$on('autofill-submit', function(e) {
        ngModel.$setViewValue(element.val());
    });
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions