I think the next solution is cleaner.
$scope.$watch('myForm', function (a, b) { $scope.myForm.$setValidity('custom', false, window);
I like $watch better; Initially, I was going to check "if the form was created yet", and only after that establish the correctness.
But it seems that this is really not necessary, the form is created before $ watch is executed its initial time (so that the clock does not cause any changes).
$setValidity seems to be part of the ngForm API (I found the source code in form.js ), and it is used by the form controls themselves, which set $ valid and $ to be invalid.
user3638471 Feb 08 '17 at 22:18 2017-02-08 22:18
source share