i'm using ng-messages show various validation messages component, so:
<ng-messages for="myform.myfield.$error" ng-if="myform.myfield.$touched"> <ng-message when="required">my field required</ng-message> <ng-message when="foo">foo message</ng-message> <ng-message when="backend">{{myform.backendmessages.myfield}}</ng-message> </ng-messages> during handling of error messages server, i'm adding customised error messages component:
myfield.$setvalidity("backend", false); myfield.$settouched(true); // ng-messages shown which working fine insofar putting messages want them, marks form "invalid", means can't use simple logic disable form submission when client-side validations triggered.
is there "blessed" way can add myfield.$error without invalidating component , form? or must reset entirety of "valid" flags once user dirties form, make message disappear? if latter, what's nicest way this?
using angular 1.4.1 fwiw.
i'm haven't used ng-messages component yet sounds using novalidate attribute work.
<form method="post" action="xyz" novalidate> ... </form> this way component validates , browser won't trigger native validation errors
Comments
Post a Comment