Created
November 25, 2014 03:58
-
-
Save darlanalves/571e80459c2043964d9e 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
angular.module('isValid') | |
.directive('isValid', function() { | |
return { | |
link: linker, | |
require: '^form' | |
}; | |
function linker($scope, $element, $attrs, form) { | |
var expression = $attrs.isValid, | |
name = $attrs.error; | |
$scope.$watch(expression, function(value) { | |
form.$setValidity(name, !!value); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment