show validation error messages on submit in angularjs

I found this fiddle http://jsfiddle.net/thomporter/ANxmv/2/ which does a nifty trick to cause control validation.

Basically it declares a scope member submitted and sets it true when you click submit. The model error binding use this extra expression to show the error message like

submitted && form.email.$error.required

UPDATE

As pointed out in @Hafez’s comment (give him some upvotes!), the Angular 1.3+ solution is simply:

form.$submitted && form.email.$error.required

Leave a Comment