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
Post a Comment