aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/parse.js
diff options
context:
space:
mode:
authorMisko Hevery2012-02-28 14:29:58 -0800
committerMisko Hevery2012-06-02 16:02:08 -0700
commit41d26db32c1c013dd33faa03df85e38681a9ebb1 (patch)
treea5be9c22e26b239129993fec416a16f33386a8c9 /src/ng/parse.js
parentdd38ce6585b0e7ffa755f4c65d78ed90204729d1 (diff)
downloadangular.js-41d26db32c1c013dd33faa03df85e38681a9ebb1.tar.bz2
docs(expression): rewrite
Diffstat (limited to 'src/ng/parse.js')
-rw-r--r--src/ng/parse.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ng/parse.js b/src/ng/parse.js
index 294e2c8d..55b0c67c 100644
--- a/src/ng/parse.js
+++ b/src/ng/parse.js
@@ -807,6 +807,39 @@ function getterFn(path, csp) {
///////////////////////////////////
+/**
+ * @ngdoc function
+ * @name angular.module.ng.$parse
+ * @function
+ *
+ * @description
+ *
+ * Converts Angular {@link guid/expression expression} into a function.
+ *
+ * <pre>
+ * 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>
+ *
+ *
+ * @param {string} expression String expression to compile.
+ * @returns {function(context, locals)} a function which represents the compiled expression:
+ *
+ * * `context`: an object against which any expressions embedded in the strings are evaluated
+ * against (Topically a scope object).
+ * * `locals`: local variables context object, useful for overriding values in `context`.
+ *
+ * The return function also has an `assign` property, if the expression is assignable, which
+ * allows one to set values to expressions.
+ *
+ */
function $ParseProvider() {
var cache = {};
this.$get = ['$filter', '$sniffer', function($filter, $sniffer) {