Angular also provides some CSS classes for forms and inputs depending on their state
Class | Description |
---|---|
ng-touched | Field has been touched |
ng-untouched | Field has not been touched |
ng-pristine | Field has not been modified |
ng-dirty | Field has been modified |
ng-valid | Field is valid |
ng-invalid | Field is invalid |
You can use these classes to add styles to your forms
input.ng-invalid {
background-color: crimson;
}
input.ng-valid {
background-color: green;
}