forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.directive.ng:src.html
25 lines (24 loc) · 1.35 KB
/
angular.directive.ng:src.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<h1>angular.directive.ng:src</h1>
<div class="angular-directive-ng-src"><fieldset class="workInProgress"><legend>Work in Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.</fieldset>
<h2>Description</h2>
<div class="description"><p>Using <tt><angular/></tt> 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 <tt><angular/></tt> replaces the expression inside
<code>{{hash}}</code>. The <code>ng:src</code> attribute solves this problem by placing
the <code>src</code> attribute in the <code>ng:</code> namespace.</p>
<p>The buggy way to write it:</p><div ng:non-bindable><pre class="brush: js; html-script: true;">
<img src="http://www.gravatar.com/avatar/{{hash}}"/>
</pre></div><p>The correct way to write it:</p><div ng:non-bindable><pre class="brush: js; html-script: true;">
<img ng:src="http://www.gravatar.com/avatar/{{hash}}"/>
</pre></div></div>
<h2>Usage</h2>
<div class="usage"><pre class="brush: js; html-script: true;"><ANY ng:src="template">
...
</ANY></pre>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">template – {template} – </code>
<p>any string which can contain <code>{{}}</code> markup.</p></li>
</ul>
</div>
</div>