If you are like me, you probably think that the best point to show to users the form errors is when the user submits the form.

I think that is a bad user experience to do:

Disable the submit button when the form is invalid — the user does not have a clue what’s wrong. Show the errors when the form is “touched” — this is very annoying, please don’t do that. Just let the user complete filing the form and then display the errors.

Let’s see how we can show the errors only after submit.

We are just exporting the ngForm directive to a local variable and uses it’s submitted property as an indication to know when the form is submitted, that’s all!