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

前端 未结 12 2577
一个人的身影
一个人的身影 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 03:00

    I was struggling with this and what was happening was my ng-messages were not appearing because the default browser behavior was not allowing invalid form submission with ng-required="true". To solve this you can decorate the form with novalidate. Here is the full working example for me:

    Name is required.

提交回复
热议问题