mining-pool/frontend/app/utils/directives.js

21 lines
No EOL
551 B
JavaScript

var compareTo = function() {
return {
require: "ngModel",
scope: {
otherModelValue: "=compareTo"
},
link: function(scope, element, attributes, ngModel) {
ngModel.$validators.compareTo = function(modelValue) {
return modelValue == scope.otherModelValue;
};
scope.$watch("otherModelValue", function() {
ngModel.$validate();
});
}
};
};
angular.module('utils.directives', [])
.directive("compareTo", compareTo);