I have a custom validation like this:
app.directive('checkRfc', function() {
return {
require: 'ngModel',
link: function(scope, element, attr, mCtrl) {
function checkRfcValidation(value) {
if (scope.clientForm.requireBill.$modelValue === "1" && value.length > 0) {
mCtrl.$setValidity('rfcOk', true);
//scope.examsForm.authorization.$setValidity("discountOk", true);
}
else {
mCtrl.$setValidity('rfcOk', false);
//scope.examsForm.authorization.$setValidity("discountOk", false);
}
return value;
}
mCtrl.$parsers.push(checkRfcValidation);
}
};
});
Works fine but I have to enter some character in the corresponding field, then the validation will be triggered. Is there a way to activate automatically the validation on form load?