forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.scope.$eval.html
30 lines (27 loc) · 1.3 KB
/
angular.scope.$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
<h1>angular.scope.$eval</h1>
<div class="angular-scope-eval"><h2>Description</h2>
<div class="description"><p>Executes the <code>expression</code> on the current scope returning the result. Any exceptions in the
expression are propagated (uncaught). This is useful when evaluating engular expressions.</p>
<h3>Example</h3><div ng:non-bindable><pre class="brush: js;">
var scope = angular.scope();
scope.a = 1;
scope.b = 2;
expect(scope.$eval('a+b')).toEqual(3);
expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3);
</pre></div></div>
<h2>Usage</h2>
<div class="usage"><div ng:non-bindable=""><pre class="brush: js; html-script: true;">angular.scope.$eval([expression]);</pre>
</div>
<h3>Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">expression<i>(optional)</i> – {(string|function())} – </code>
<p>An angular expression to be executed.</p>
<ul>
<li><code>string</code>: execute using the rules as defined in <a href="#!/guide/dev_guide.expressions">expression</a>.</li>
<li><code>function(scope)</code>: execute the function with the current <code>scope</code> parameter.</li>
</ul></li>
</ul>
<h3>Returns</h3>
<div class="returns"><code ng:non-bindable="">{*}</code>
– <p>The result of evaluating the expression.</p></div>
</div>
</div>