In your case, you can try ng-class:
<input type="text" ng-class="{highlight:register.name.$error.required || register.name.$error.minlength || register.name.$error.maxlength}" name="name" ng-model="name" required ng-minlength="5" ng-maxlength="32">
Demo
Another solution is to style for these classes:
ng-valid ng-invalid ng-pristine ng-dirty
Angular automatically switches these classes based on the current validation state. The following is a demonstration of invalid input:
input.ng-invalid { background:#F84072; border: 2px red solid; }
Demo
source share