javascript - Trouble with Angular Validation -



javascript - Trouble with Angular Validation -

i'm new angular , have problem debugging utilize of form validations. namely want disable sumbit button if form invalid. problem stays invalid if i've inserted apparently valid input. goes far invalid empty form:

this template (original code commented out):

<div> <div class="row"> <div class="col-xs-6"> <a href ng-click="companiesctrl.newedit()" class="btn btn-primary">uus asutus</a> <table class="table"> <tbody> <tr ng-repeat="company in companiesctrl.list"> <td><a href ng-click="companiesctrl.load(company)">{{company.name}}</a></td> </tr> </tbody> </table> </div> <div class="col-xs-6"> <form id="editform"> <!--<form ng-show="companiesctrl.showedit()" ng-submit="companiesctrl.save()" name="editform">--> <!--<h4>asutuse detailid</h4>--> <!--<a ng-show="companiesctrl.edit.id != 0" class="btn btn-primary" ng-href="../{{companiesctrl.edit.id}}/product/list">asutuse vaatele</a>--> <!--<fieldset class="form-group">--> <!--<input ng-model="companiesctrl.edit.id"/>--> <!--</fieldset>--> <!--<fieldset class="form-group">--> <!--<input placeholder="asutuse nimi" title="asutuse nimi" ng-model="companiesctrl.edit.name" ng-required="true"/>--> <!--</fieldset>--> <!--<fieldset class="form-group">--> <!--<input type="submit" class="btn btn-success" ng-disabled="editform.$invalid" value="salvesta" />--> <!--</fieldset>--> </form> <span>{{editform.$error}}</span> <span>{{editform.$invalid}}</span> <span>{{editform.$valid}}</span> </div> </div>

and result "span"-s:

{"required":[{}]} true false

my question is, i'm new angular, how debug this, or additional factors can impact form "valid" status.

i managed find problem myself. had multiple directives hidden ng-show. of them had form named "editform" cause angular validate forms.

just if ever needs debugging: added next template:

<span ng-repeat="error in compform.$error"><span ng-repeat="error2 in error"> {{companiesctrl.logthis(error2)}}</span></span>

and next controller:

this.logthis = function(tolog) { console.log(tolog); }

from log saw validating many times , quessed problem.

javascript angularjs forms validation

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -