title: Angular $compile in link function gives an error "RangeError: Maximum call stack size exceeded"
body: <p>I am trying to add a ng-class attribute to a custom directive from the link function. But when using compile function after adding the ng-class attribute, It throws an error like "RangeError: Maximum call stack size exceeded"</p>
  
  <p>Please see the code below</p>
  
  <pre><code>MyApp.directive('twinField',function($compile){
  return {
      restrict:'A',
      require:'ngModel',
      scope:{
          fval:'='
      },
      link:function(scope,ele,attr,ctrl){
          ctrl.$validators.compareTo=function(val){
              //alert(scope.fval)
              return scope.fval==val
          }
          scope.$watch('fval', function(newValue, oldValue, scope) {
              ctrl.$validate()
          });
          ele.attr("ng-class","addForm.cpassword.$error.compareTo?'errorpswd':''")//=""
          $compile(ele)(scope);
      }
  }
  </code></pre>
  
  <p>})</p>
  
  <p>It is working when I add the ng-class directly in the html.</p>