Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
app.directive('focus', function() {
return function(scope, element) {
app.directive('passwordMatch', [function () {
return {
restrict: 'A',
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);
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