Skip to content

Instantly share code, notes, and snippets.

@AntonisFK
Created November 22, 2016 20:05
Show Gist options
  • Save AntonisFK/61136c73bee36a972391d4ebf42a349a to your computer and use it in GitHub Desktop.
Save AntonisFK/61136c73bee36a972391d4ebf42a349a to your computer and use it in GitHub Desktop.
directive used for email or password confirmation.
.directive('match', function($parse) {
return {
require: 'ngModel',
link: function(scope, elem, attrs, ctrl) {
scope.$watch(function() {
return $parse(attrs.match)(scope) === ctrl.$modelValue;
}, function(currentValue) {
ctrl.$setValidity('mismatch', currentValue);
});
}
};
});
// <input type="password" name="passwordConfirm" ng-model="$ctrl.user.passwordConfirm" match="$ctrl.user.password" required/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment