In my from I have several inputs with validation, I need for the ng-invalid
class to only be applied once the user has submitted the form.
On submit I can set a value on the scope as such...
$scope.submitForm = function () {
$scope.submited = true;
// other bits
}
... but I cant figure out how to conditionally display ng-invalid
without changing the validation itself.
I am running angular 1.1.5
For custom errors I suggest to use the $setValidity method within each field.
so you will have more control over the css part too, because this kind of workflow will create also a custom class inside your field like "ng-custom_error_name" so you can deal with that.
Demo
Use $dirty flag to show the error only after user interacted with the input: