AngularJS : How to access generated data from a directive?
<p>I have been working with AngularJS for months. Today, I need to create a directive that will help me add a fix header to a table. All the directives I've found were not good enough because of the way they deal with the columns size (I'm still opened for propositions).</p>

<p>We use an "old" function made with jQuery and I am trying to convert it to a directive. The goal is, to clone the table (or the header of the table) and deals with hide/show functions and its position to get a good result.</p>

<p>My problem: the header of my table is dynamic with generated columns:</p>

<pre><code>&lt;table&gt;
      &lt;thead&gt;
             &lt;tr&gt;
                  &lt;th&gt;&lt;/th&gt; // true th elements, used for styling my table
                  &lt;th&gt;&lt;/th&gt;
                  &lt;th class='text-center' ng-repeat="thing in things"&gt;
                      {{thing.label}}
                  &lt;/th&gt;
             &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          // my tbody
     &lt;/tbody&gt;
&lt;/table&gt;
</code></pre>

<p>I'm trying to get the <code>&lt;th&gt;</code> element in my directive with something like that :</p>

<pre><code>angular.forEach(elem.querySelectorAll('tr:first-child th'), function    (thElem, i) {
        console.log(thElem)
        // do stuff here
    }
});
</code></pre>

<p>But I just get the two first <code>&lt;th&gt;</code> which are the "true" elements in my code. All others, generated by the ng-repeat are ignored. Or not injected in my directive.</p>

<p>I've looking around the transclude attribute but I could not find anything that works. Can you help me with some precision?</p>

<p>EDIT : Here is the beginning of my directive:</p>

<pre><code>myApp.directive('fixMe', function ($window) {
     return {
       restrict: 'A',
       link: function (scope, element, attrs) {
          angular.forEach(element.querySelectorAll('th'), function (thElem, i) {
            console.log(thElem);
            var columnWidth = thElem.offsetWidth;
            thElem.style.width = columnWidth + 'px';
        });

       }
    };
})
</code></pre>