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

1

6

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.

Salliesallow answered 17/10, 2014 at 11:38 Comment(2)
did you try tElem.contents() from within compile?Darkroom
of course. It returns the contents of the directive's template.Salliesallow
B
5

Set terminal: true, and manually compile the directive.

Beem answered 3/12, 2014 at 3:42 Comment(1)
Set terminal: true for which directive? And manually compile which directive?Aurlie

© 2022 - 2024 — McMap. All rights reserved.