Ronan Rafferty
Ronan Rafferty

Reputation: 189

Directive compile function, adds html but then gets overwritten

I have an directive. I want it to read configuration options from a table head then build out the tbody tr with angular expressions (ng-repeat) at the compile stage.

I have debugged and can get to a stage where I can see the HTML in the DOM in firebug on a breakpoint after the insertion. I have also debugged the point where it is removed and its on the applyDirectivesToNode function. I can't figure out the correct configuration of transclude.

Here's a fiddle. Any help would be amazing. Line 32 is where I append the HTML http://jsfiddle.net/raff77/eGUhF/2/

  tBody.append(html);

Upvotes: 0

Views: 130

Answers (1)

Ye Liu
Ye Liu

Reputation: 8986

I made some changes to the original fiddle to make it work:

  1. Use datatable instead of data-table in HTML
  2. Line 22, use find('th') instead of find('thead > tr > th') because of the limitation of jqLite
  3. Line 23, use dataset instead of chartdata
  4. Line 32, use tBody[0].innerHTML = html instead of tBody.append(html)

Check the updated fiddle out, I have "FIXED" comments in it to further clarify some of the issues.

Upvotes: 1

Related Questions