Q:

Add class to input parent

I need to add class to input parent if input is not empty or focus because I want to change label position.
<div class="input-field">
    <input type="email" name="email" ng-model="email" required />
    <label for="email">Email</label>
</div>

I can do this:
<div class="input-field" ng-class="{ active: signIn.email.$viewValue.length > 0 || isFocus }">
    <input type="email" name="email" ng-model="email" ng-focus="isFocus=true" ng-blur="isFocus=false" required />
    <label for="email">Email</label>
</div>

But I have many inputs and my code will be very large and ugly.
How can I do it better?
Thank you.

A:

Go with attribute directive where you can have logic which class you need to add to input-filed.
angular.directive('myClass', function() {
  return {
    restrict: 'A',   
    link: function (scope, element,attr) {
      // your logic
    }
  };

or 
$scope.myClass = "";
<div class="input-field" ng-class="myClass" />

angularjs : setting class attribute in a directive template

