29 lines
1.1 KiB
HTML
29 lines
1.1 KiB
HTML
<h1><code ng:non-bindable="">ngSrc</code>
|
||
<span class="hint">(directive in module <code ng:non-bindable="">ng</code>
|
||
)</span>
|
||
</h1>
|
||
<div><h2 id="Description">Description</h2>
|
||
<div class="description"><p>Using Angular markup like <code>{{hash}}</code> in a <code>src</code> attribute doesn't
|
||
work right: The browser will fetch from the URL with the literal
|
||
text <code>{{hash}}</code> until Angular replaces the expression inside
|
||
<code>{{hash}}</code>. The <code>ngSrc</code> directive solves this problem.</p>
|
||
|
||
<p>The buggy way to write it:
|
||
<pre class="prettyprint linenums">
|
||
<img src="http://www.gravatar.com/avatar/{{hash}}"/>
|
||
</pre>
|
||
|
||
<p>The correct way to write it:
|
||
<pre class="prettyprint linenums">
|
||
<img ng-src="http://www.gravatar.com/avatar/{{hash}}"/>
|
||
</pre></div>
|
||
<h2 id="Usage">Usage</h2>
|
||
<div class="usage">as attribute<pre class="prettyprint linenums"><IMG ng-src="{template}">
|
||
...
|
||
</IMG></pre>
|
||
<h3 id="Parameters">Parameters</h3>
|
||
<ul class="parameters"><li><code ng:non-bindable="">ngSrc – {template} – </code>
|
||
<p>any string which can contain <code>{{}}</code> markup.</p></li>
|
||
</ul>
|
||
</div>
|
||
</div>
|