16 lines
No EOL
459 B
JavaScript
16 lines
No EOL
459 B
JavaScript
/**
|
|
* Adds a 'match' attribute that ensures that a form field's value matches another field's
|
|
* value.
|
|
*/
|
|
angular.module('quay').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);
|
|
});
|
|
}
|
|
};
|
|
}); |