Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent angularjs directive compilation (use as a template)
    primarykey
    data
    text
    <p>I just wanted to know if it is possible to prevent the compilation of angularjs directives ?</p> <p>I use the jQuery Slick Grid plugin to display some datagrids in my website, and I imagined a way to define easily the cells templates with nested directives containing HTML.</p> <p>The problem is that this HTML code is meant to be used as a template but AngularJS compiles it before the grid is initialized! (seems logical though...)</p> <p>Thanks in advance !</p> <p>EDIT: Here is an example of my directive.</p> <pre><code>&lt;div class="datagrid" my-datagrid="o in collection"&gt; &lt;div my-datagrid-column="col1"&gt; &lt;div&gt;{{o.col1}}&lt;/div&gt; &lt;/div&gt; &lt;div my-datagrid-column="col2"&gt; &lt;div custom-directive-with-transclusion="foobar"&gt;{{o.col2}}&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>So here it is, I have a parent directive <code>my-datagrid</code>which contains several <code>my-datagrid-column</code> describing each columns of the grid. Eech of these <code>my-datagrid-column</code> directive node contains HTML content which purpose is to be used as a template for the grid cells, <strong>at the time they will be rendered</strong>.</p> <p>The problem is that, the engine "sees" and compiles, transclude the <code>custom-directive-with-transclusion</code> directive <strong>before</strong> the <code>my-datagrid</code> directive creates the Datagrid.</p> <p>So the my <code>datagrid-column</code> directive get an already compiled cell "template"...and I don't want that, I want to compile each cell myself with the <code>$compile</code> service.</p> <p>Maybe it is not the way to do that, maybe I'm going totally in the wrong way. I just want to avoid describing the cell template in the Javascript controller between some ugly quotes and escaping everything like :</p> <pre><code>template[0] = '&lt;div&gt;this is my ugly template {{myCol1}} of my first column&lt;/div&gt;'; template[1] = '&lt;div&gt;this is my ugly template {{myCol2}} of the 2nd column&lt;/div&gt;'; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload