Is there a way to set an input validity inside a directive? The input present in the directive\'s template.
Lets say I have template:
You don't need to use elem in order to get the controller, just add it as a param to the link function, and set require to ['ngModel'] in order to get the model ctrl.
require: ['ngModel'],
link: function (scope, elem, attrs, ctrl) {
someObj = {val: '123'};
scope.check = function () {
var result = false;
ctrl.$setValidity(result);
};
}