I've created a custom directive shakeThat which has two scope variables. The first one submit calls the parent controller function submit() when the form is valid. The second one submitted is a Boolean value and false at the beginning. It simply defers the activation of error classes until the user clicks on the 'Login' button. Check out AngularJS Form Validation for more information about the submitted variable.