22 lines
543 B
JavaScript
22 lines
543 B
JavaScript
'use strict';
|
|
/**
|
|
* Password-check directive.
|
|
*/
|
|
app.directive('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();
|
|
});
|
|
}
|
|
};
|
|
}); |