Skip to content

Instantly share code, notes, and snippets.

@sahat
Created December 27, 2014 05:16
Show Gist options
  • Save sahat/0f4c915793458753397b to your computer and use it in GitHub Desktop.
Save sahat/0f4c915793458753397b to your computer and use it in GitHub Desktop.
Confirm Password
angular.module('MyApp')
.directive('repeatPassword', function() {
return {
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
var otherInput = elem.inheritedData("$formController")[attrs.repeatPassword];
ctrl.$parsers.push(function(value) {
if (value === otherInput.$viewValue) {
ctrl.$setValidity('repeat', true);
return value;
}
ctrl.$setValidity('repeat', false);
});
otherInput.$parsers.push(function(value) {
ctrl.$setValidity('repeat', value === ctrl.$viewValue);
return value;
});
}
};
});
@LOZORD
Copy link

LOZORD commented Dec 29, 2014

What would the corresponding HTML look like?

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