consumerportal
Version:
mydna Custimised for you
46 lines (31 loc) • 962 B
text/typescript
/// <reference path="../includes.ts" />
/*
Usage:
<label>Confirm Password</label>
<input ng-model="vm.frm.ConfirmPassword" password-matcher="Password">
=>
ConfirmPassword $invalid or $valid
*/
((): void => {
'use strict';
function passwordMatcher(): angular.IDirective {
var directive = <angular.IDirective>{
restrict: 'A',
require: 'ngModel',
scope: true,
link: link
};
function link(scope: angular.IScope, elm: angular.IAugmentedJQuery, attrs, ctrl: angular.INgModelController) {
var isEqual = function() {
var firstPassword = scope.$eval(attrs.ngModel);
var verifyPassword = scope.$eval(attrs.passwordMatcher);
return firstPassword == verifyPassword;
};
scope.$watch(isEqual, function(n) {
ctrl.$setValidity("isunique", n);
});
}
return directive;
}
angular.module('passwordMatcher', []).directive('passwordMatcher', passwordMatcher);
})();