Simplify form error input handling
The form-input class now has the directive responsible for setting the error classes. It watches its scope and sets the errors only if the model is defined or pristine. This guard keeps the error class from being set until validation passes (when the model becomes defined) and keeps it from being cleared until the pristine state is reset. The form-validate directive is now just a controller for form-input to register with. It sets all fields to dirty and forces a render on submit. These mechanisms are better all around than trying to listen for a the model to be undefined and setting pristine automatically. The model is undefined whenever validation is failing. There are times when the from should maybe be cleared but still show errors. Now, it is left up to other code to set pristine if the form should be reset.
Showing
Please register or sign in to comment