<input type="text" class ="errorhilight" ng-model="name" ng-class="{'errorhilight': (name == '' || name == 'undefined')}">
Lets look what you are doing wrong . Here you added the class class ="errorhilight"
with and without the condition remove that .
2nd part keep a variable for highlights . Make it true when button is clicked like @Yury Tarabanko solution . But the best way would be to use from validators.
<form id="testForm" name="testForm" ng-submit="validate()" novalidate>
<input type="text" ng-model="name" name="name"
ng-class="{errorhilight: buttonClicked && testForm.name.$invalid}" required >
<input type="submit" ng-click="validate();">
</form>
and in the controller
$scope.buttonClicked = false;
$scope.validate = function(){
$scope.buttonClicked = true;
}