Last active
March 27, 2017 16:45
-
-
Save itswadesh/4226776ec0f29be966e864e953ebbf23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.directive('focus', function() { | |
return function(scope, element) { | |
element[0].focus(); | |
} | |
}); | |
app.directive('passwordMatch', [function () { | |
return { | |
restrict: 'A', | |
scope:true, | |
require: 'ngModel', | |
link: function (scope, elem , attrs,control) { | |
var checker = function () { | |
//get the value of the first password | |
var e1 = scope.$eval(attrs.ngModel); | |
//get the value of the other password | |
var e2 = scope.$eval(attrs.passwordMatch); | |
if(e2!=null) | |
return e1 == e2; | |
}; | |
scope.$watch(checker, function (n) { | |
//set the form control to valid if both | |
//passwords are the same, else invalid | |
control.$setValidity("passwordNoMatch", n); | |
}); | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment