javascript - AngularJS form $valid set to true before validation completes -


i displaying validation symbol in left nav of page indicate whether form valid or not. when load page form's $valid attribute set true, changes false (as should given retrieved input data). result validation symbol flickering valid invalid. there way prevent this? validation symbol tied valid attribute on $scope, gets set within watch. there logic added watch check if form hasn't finished initializing or validating? thanks!

here current watch code. valid attribute goes undefined true false after couple different watch cycles.

$scope.$watch( 'sections.' + section.sectionname + '.sectionform.$valid', function( valid ) {     section.valid = valid; }, true); 

and html display validation symbol:

<span ng-class="{ 'fa fa-check': section.valid,     'fa fa-warning': !section.valid}"> </span> 

i think problem $watch function. first time set "section.valid" undefined. don't need watch manually. each form directive creates instance of formcontroller. so, can check form validity directly in view.

<span ng-class="{'fa fa-check': sectionformname.$valid, 'fa fa-warning': sectionformname.$invalid}"></span> 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -