Skip to content

Instantly share code, notes, and snippets.

@thekarel
Created October 28, 2013 14:13
Show Gist options
  • Save thekarel/7197440 to your computer and use it in GitHub Desktop.
Save thekarel/7197440 to your computer and use it in GitHub Desktop.
Watch form $valid in a child element in AngularJS
angular.module('foo', []).directive('enableifformisvalid', function() {
return {
restrict: 'A',
require: '^form',
link: function(scope, element, attrs, formCtrl) {
window.f = formCtrl;
scope.$watch(function() {return formCtrl.$valid;}, function(newVal, oldVal) {
console && console.log('newVal', newVal);
console && console.log('oldVal', oldVal);
});
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment