app.directive('pwdconfirm', function(){ return { require: 'ngModel', link: function(scope, elm, attrs, ctrl){ ctrl.$validators.pwdconfirm = function(modelValue, viewValue) { return scope.user && scope.user.password == viewValue; } } } });