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());
});
}
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: