forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.directive.ng:eval.html
32 lines (32 loc) · 1.61 KB
/
angular.directive.ng:eval.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
<h1>angular.directive.ng:eval</h1>
<div class="angular-directive-ng-eval"><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>The <code>ng:eval</code> allows you to execute a binding which has side effects
without displaying the result to the user.</p></div>
<h2>Dependencies</h2>
<ul class="dependencies"></ul>
<h2>Usage</h2>
<div class="usage"><pre class="brush: js; html-script: true;"><ANY ng:eval="expression">
...
</ANY></pre>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">expression – {expression} – </code>
<p>to eval.</p></li>
</ul>
</div>
<h2>Example</h2>
<div class="example"><p>Notice that <code>{{</code> <code>obj.multiplied = obj.a * obj.b</code> <code>}}</code> has a side effect of assigning
a value to <code>obj.multiplied</code> and displaying the result to the user. Sometimes,
however, it is desirable to execute a side effect without showing the value to
the user. In such a case <code>ng:eval</code> allows you to execute code without updating
the display.</p><doc:example><doc:source><input name="obj.a" value="6" >
* <input name="obj.b" value="2">
= {{obj.multiplied = obj.a * obj.b}} <br>
<span ng:eval="obj.divide = obj.a / obj.b"></span>
<span ng:eval="obj.updateCount = 1 + (obj.updateCount||0)"></span>
<tt>obj.divide = {{obj.divide}}</tt><br/>
<tt>obj.updateCount = {{obj.updateCount}}</tt></doc:source>
</doc:example>
</div>
</div>