UNPKG

knowhow-server

Version:

A personal workflow engine that can manage and use any network connected host

42 lines (40 loc) 2.65 kB
<a href="http://github.com/angular/angular.js/tree/v1.2.9/src/ng/parse.js#L1085" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/parse.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">$parse</code> <div><span class="hint">service in module <code ng:non-bindable="">ng</code> </span> </div> </h1> <div><h2 id="description">Description</h2> <div class="description"><div class="ng-parse-page"><p>Converts Angular <a href="guide/expression">expression</a> into a function.</p> <pre class="prettyprint linenums"> var getter = $parse('user.name'); var setter = getter.assign; var context = {user:{name:'angular'}}; var locals = {user:{name:'local'}}; expect(getter(context)).toEqual('angular'); setter(context, 'newValue'); expect(context.user.name).toEqual('newValue'); expect(getter(context, locals)).toEqual('local'); </pre> </div></div> <h2 id="usage">Usage</h2> <div class="usage"><pre class="prettyprint linenums">$parse(expression);</pre> <h4 id="usage_parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>expression</td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ng-parse-page"><p>String expression to compile.</p> </div></td></tr></tbody></table><h4 id="usage_returns">Returns</h4><table class="variables-matrix"><tr><td><a href="" class="label type-hint type-hint-function">function(context, locals)</a></td><td><div class="ng-parse-page"><p>a function which represents the compiled expression:</p> <ul> <li><code>context</code><code>{object}</code> – an object against which any expressions embedded in the strings are evaluated against (typically a scope object).</li> <li><p><code>locals</code><code>{object=}</code> – local variables context object, useful for overriding values in <code>context</code>.</p> <p>The returned function also has the following properties:</p> <ul> <li><code>literal</code><code>{boolean}</code> – whether the expression&#39;s top-level node is a JavaScript literal.</li> <li><code>constant</code><code>{boolean}</code> – whether the expression is made entirely of JavaScript constant literals.</li> <li><code>assign</code><code>{?function(context, value)}</code> – if the expression is assignable, this will be set to a function to change its value on the given context.</li> </ul> </li> </ul> </div></td></tr></table></div> </div>