1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/static/js/directives/match.js
2019-11-12 11:09:47 -05:00

16 lines
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);
});
}
};
});