Skip to content

Instantly share code, notes, and snippets.

@darlanalves
Created November 25, 2014 03:58
Show Gist options
  • Save darlanalves/571e80459c2043964d9e to your computer and use it in GitHub Desktop.
Save darlanalves/571e80459c2043964d9e to your computer and use it in GitHub Desktop.
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