css - Angular ngMessages change class when valid and not only on error -


it's first time working ngmessages , question if $error object has counterpart, $valid? in angular documentation ngmessages came across $error object.

<form name="contactform">      <input ng-class="{'invalid-field': contactform.namefield.$error, 'valid-field': !contactform.namefield.$error}" type="text" name="namefield" placeholder="full name*" required>      <div ng-messages="contactform.namefield.$error">         <div ng-message="required">name required</div>     </div>  </form> 

what i'm doing know when $error object false change class 'valid-field' isn't correct. way input field formatted it's valid , isn't supposed happening.

based on documentation ng-model, $error comes from, have $valid state answer question, yes :)

documentation show other validation related angular model states.

https://docs.angularjs.org/api/ng/type/ngmodel.ngmodelcontroller

$valid: boolean: true if there no error.

ng-model attribute should use each field though when here in example input not have ng-model source of problem.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -