Created
December 27, 2014 05:16
-
-
Save sahat/0f4c915793458753397b to your computer and use it in GitHub Desktop.
Confirm Password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What would the corresponding HTML look like?