forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng.$interpolate.html
62 lines (58 loc) · 2.78 KB
/
ng.$interpolate.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<h1><code ng:non-bindable="">$interpolate</code>
<span class="hint">(service in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><p>Compiles a string with markup into an interpolation function. This service is used by the
HTML <a href="api/ng.$compile"><code>$compile</code></a> service for data binding. See
<a href="api/ng.$interpolateProvider"><code>$interpolateProvider</code></a> for configuring the
interpolation markup.</p>
<pre><code> <pre class="prettyprint linenums">
var $interpolate = ...; // injected
var exp = $interpolate('Hello {{name}}!');
expect(exp({name:'Angular'}).toEqual('Hello Angular!');
</pre>
</code></pre></div>
<h2 id="Dependencies">Dependencies</h2>
<ul class="dependencies"><li><code ng:non-bindable=""><a href="api/ng.$parse">$parse</a></code>
</li>
</ul>
<h2 id="Usage">Usage</h2>
<div class="usage"><pre class="prettyprint linenums">$interpolate(text[, mustHaveExpression]);</pre>
<h3 id="Parameters">Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">text – {string} – </code>
<p>The text with markup to interpolate.</p></li>
<li><code ng:non-bindable="">mustHaveExpression<i>(optional)</i> – {boolean=} – </code>
<p>if set to true then the interpolation string must have
embedded expression in order to return an interpolation function. Strings with no
embedded expression will return null for the interpolation function.</p></li>
</ul>
<h3 id="Returns">Returns</h3>
<div class="returns"><code ng:non-bindable="">{function(context)}</code>
– <p>an interpolation function which is used to compute the interpolated
string. The function has these parameters:</p>
<ul>
<li><code>context</code>: an object against which any expressions embedded in the strings are evaluated
against.</li>
</ul></div>
</div>
<div class="member method"><h2 id="Methods">Methods</h2>
<ul class="methods"><li><h3 id="endSymbol">endSymbol()</h3>
<div class="endsymbol"><p>Symbol to denote the end of expression in the interpolated string. Defaults to <code>}}</code>.</p>
<p>Use <a href="api/ng.$interpolateProvider#endSymbol"><code>$interpolateProvider#endSymbol</code></a> to change
the symbol.</p><h4 id="Returns">Returns</h4>
<div class="returns"><code ng:non-bindable="">{string}</code>
– <p>start symbol.</p></div>
</div>
</li>
<li><h3 id="startSymbol">startSymbol()</h3>
<div class="startsymbol"><p>Symbol to denote the start of expression in the interpolated string. Defaults to <code>{{</code>.</p>
<p>Use <a href="api/ng.$interpolateProvider#startSymbol"><code>$interpolateProvider#startSymbol</code></a> to change
the symbol.</p><h4 id="Returns">Returns</h4>
<div class="returns"><code ng:non-bindable="">{string}</code>
– <p>start symbol.</p></div>
</div>
</li>
</ul>
</div>
</div>