title: How to reliably access dynamically assigned attribute values from a separate directive?
body: <p>I'm writing an Angular directive to wrap a third party plugin I want to use in my application. The plugin needs to read the classes assigned to the element I'm using my custom directive on. I'm able to access the class attribute fine when doing static class assignment in the markup; but if I use <code>ngClass</code> to assign an additional class dynamically to my element, it is invisible to my custom directive.</p>
  
  <p>I have written up a simple plunkr to demonstrate the issue below:</p>
  
  <p><a href="http://plnkr.co/edit/i5iBwlKXuvrdjF85wiIU?p=preview" rel="nofollow">http://plnkr.co/edit/i5iBwlKXuvrdjF85wiIU?p=preview</a></p>
  
  <p>But the thrust of it is contained here:</p>
  
  <pre><code>&lt;body ng-controller="MainCtrl"&gt; 
    &lt;div class="staticAssignment"
      ng-class="cssClass"
      my-directive&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>app.controller('MainCtrl', function($scope) {
    $scope.cssClass = 'dynamicAssignment';
  });
  
  app.directive("myDirective", function () {
    return {
      link: function (scope, element, attr) {
        console.log("my classes: ", element.attr('class'))
      }
    };
  }); 
  </code></pre>
  
  <p>When the directive's <code>link</code> function executes, I expect it to log:
  <code>"staticAssignment dynamicAssignment"</code>,
  but the dynamically assigned class is not seen at the time of linking.</p>
  
  <p>Wrapping the content of my <code>link</code> function in a <code>$timeout</code> resolves this, but it still raises the question: is there a reliable way to define the order in which your various directives are evaluated on a given element? Ideally I'd want <code>myDirective</code> to explicitly wait for <code>ngClass</code> to finish its jazz before going through with its own actions.</p>
  
  <p>Thanks!</p>