Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In your link function, you are compiling and linking the <code>img</code> where the popover directive is used.</p> <pre><code>var milesHtml = '&lt;img popover="End-to-end support" width="20" height="20" src="./img/info.png"/&gt;'; var compiledMilesHtml = $compile(milesHtml)(scope); </code></pre> <p>This hooks up DOM with events and scope and gives you a final node: <code>compiledMilesHtml</code>. You are then abandoning all of this and binding just the HTML into your displayed DOM</p> <pre><code>template: '&lt;span class="test" ng-bind-html="milestonesHTML"&gt;&lt;/span&gt;', scope.milestonesHTML = compiledMilesHtml[0].outerHTML; </code></pre> <p>This is just text, and has no knowledge about how events are hooked up or what watchers on the scope or other workings should be doing to your element. All that remains is the original DOM transformations.</p> <p>If you do need to compile the node manually, you can do so and insert the actual element, <code>compiledMilesHtml</code>, into the DOM with jQuery or jQLite. However, your template is already being compiled, linked and inserted into the DOM. Without any other special requirements, your <code>img</code> should just be placed in your template, where it will work fine.</p> <pre><code>template: '&lt;span class="test"&gt;&lt;img popover="End-to-end support" width="20" height="20" src="./img/info.png"/&gt;&lt;/span&gt;' </code></pre> <p>Demo <a href="http://plnkr.co/edit/9Vws8JJXM9tBj5rJNaUg?p=preview" rel="nofollow">here</a>. I have changed the attributes passed to the popover to match in the custom directive and HTML versions.</p>
 

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