i have angular directive used attribute validating input.
input looks (jade)
input.form-control(type='text', name='subjectinput', id='subjectinput', subjectid-noprefix-validator='(subject.nosuffix==1)')
and validator looks
.directive('subjectidnoprefixvalidator', function () { return { require: ['^form', 'ngmodel'], scope: { noprefixformat: '=subjectidnoprefixvalidator' }, link: function (scope, element, attrs, ctrls) { scope.form = ctrls[0]; // can use form reference in displaying error messages var ngmodel = ctrls[1]; ngmodel.$validators.subjectidnoprefix = function (value) { var status = true; // removed logic sets status true or false // using $scope.noprefixformat parameter return status; }; } }; });
it works fine. however, in page actions event happens need validation re-triggered on input without touching it; radio button alteration should re-trigger , refresh validation status (as see, validator has parameter).
i tried achieve calling in page controller
$scope.subjcreationform.subjectinput.$validate();
but not seem work. case , there way trigger validation of field programmatically when employs $validators?
found core of problem, $apply has called manually can achieved such:
$timeout(function () { $scope.subjcreationform.subjectinput.$validate(); });
Comments
Post a Comment