i like to watch the validity of an input element inside a directive. My controller is always undefined. How can i watch properties like $valid, $invalid on a input element ?
app.directive("myElement", function()
{
return {
restrict: "A",
templateUrl: "./Templates/tooltip.html",
scope: {
},
compile: function (element, attrs) {
return {
pre: function preLink(scope, element, attrs, controller) {
},
post: function postLink(scope, element, attrs, controller) {
scope.$watch(function(){return controller.$invalid;},function(newVal,oldVal){
});
}
}
}
}
controller.$invalidonly works if the controller is a FormController docs.angularjs.org/api/ng.directive:form.FormController