Trying to integrate Angular Auto Validate's password matching/confirmation example into a form. I'm not getting any errors but the password matching code is not kicking in. What's the simplest way to fix this? What am I doing wrong?
Here's the password matching code I'm trying to integrate:
function ConfirmPasswordValidatorDirective(defaultErrorMessageResolver) {
defaultErrorMessageResolver.getErrorMessages().then(function (errorMessages) {
errorMessages['confirmPassword'] = 'Please ensure the passwords match.';
});
return {
restrict : 'A',
require : 'ngModel',
scope : {
confirmPassword : '=confirmPassword'
},
link : function(scope, element, attributes, ngModel) {
ngModel.$validators.confirmPassword = function(modelValue) {
return modelValue === scope.confirmPassword;
};
scope.$watch('confirmPassword', function() {
ngModel.$validate();
});
}
};
}
ConfirmPasswordValidatorDirective.$inject = [
'defaultErrorMessageResolver'
];
Here's a plunkr of angular-auto-validate's password matching code working.