Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS : How to get the uncompiled transclude content of a directive

I'm trying to use the transclude content of a directive (the original content of the directive, not the template), as the HTML template of a row in a grid.

<grid attrs="...">
    <action-column-template>...(html I need)...</action-column-template>
</grid>

The idea is that I need the action-column-template's raw HTML (uncompiled, unbinded to any scope).

I do not control the generation of each row, so I can't manually bind that action template to each row's scope using transclude(rowScope). I just need it as plain html (i.e. with "{{ }}"s and inner directives untouched).

Running the transclude() fn from the link function gives me the transcluded content, but binded to a scope and with inner directives expanded. And the html() of the tElem param of the compile function returns the HTML of the directive's template, not the content to be transcluded.

So the question is: can I get the content-to-be-transcluded of a directive in its compile, controller, preLink or postLink functions as uncompiled HTML?

Thank you.

like image 935
cipak Avatar asked Oct 17 '14 11:10

cipak


1 Answers

Set terminal: true, and manually compile the directive.

like image 161
Chris Fan Avatar answered Oct 04 '22 17:10

Chris Fan