How to make ngMessage for required fields only show when dirty or submitting a form?

前端 未结 12 2591
一个人的身影
一个人的身影 2020-12-08 02:31

I\'m using AngularJS 1.3.0 RC0 and angular-messages. ng-messages dutifully shows error messages for those \"required\" fields when a form is initially loaded and pristine. S

12条回答
  •  臣服心动
    2020-12-08 02:59

    I found this answer helpful, but it didn't solve the problem of the error message hanging around forever. I came up with a slightly more complex use of show and hide as follows:

    Your name is required.

    By adding ng-hide on the message generated when an error occurs, the message disappears when the user corrects the error. Way cool. I LOVE angular.

提交回复
热议问题