From 209f4f3e0f19b30b6739aa2dd0b141bc89428b43 Mon Sep 17 00:00:00 2001 From: pholly Date: Fri, 29 May 2015 14:56:19 -0400 Subject: [PATCH] docs(guide/Expressions): added special case for one-time binding of object literals under Value stabilization algorithm One time binding of object literals are treated differently than simple expressions. Added a link to Ben Nadel's article describing how object literals's keys are checked for undefined. Closes #11982 --- docs/content/guide/expression.ngdoc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/content/guide/expression.ngdoc b/docs/content/guide/expression.ngdoc index 791bae5aa..c8f2f2c9b 100644 --- a/docs/content/guide/expression.ngdoc +++ b/docs/content/guide/expression.ngdoc @@ -28,13 +28,13 @@ Angular expressions are like JavaScript expressions with the following differenc * **No Control Flow Statements:** You cannot use the following in an Angular expression: conditionals, loops, or exceptions. - + * **No Function Declarations:** You cannot declare functions in an Angular expression, even inside `ng-init` directive. - - * **No RegExp Creation With Literal Notation:** You cannot create regular expressions + + * **No RegExp Creation With Literal Notation:** You cannot create regular expressions in an Angular expression. - + * **No Comma And Void Operators:** You cannot use `,` or `void` in an Angular expression. * **Filters:** You can use {@link guide/filter filters} within expressions to format data before @@ -175,7 +175,7 @@ expression, delegate to a JavaScript method instead. ## No function declarations or RegExp creation with literal notation You can't declare functions or create regular expressions from within AngularJS expressions. This is -to avoid complex model transformation logic inside templates. Such logic is better placed in a +to avoid complex model transformation logic inside templates. Such logic is better placed in a controller or in a dedicated filter where it can be tested properly. ## `$event` @@ -303,10 +303,14 @@ then the expression is not fulfilled and will remain watched. keep dirty-checking the watch in the future digest loops by following the same algorithm starting from step 1 +#### Special case for object literals + +Unlike simple values, object-literals are watched until every key is defined. +See http://www.bennadel.com/blog/2760-one-time-data-bindings-for-object-literal-expressions-in-angularjs-1-3.htm ### How to benefit from one-time binding -If the expression will not change once set, it is a candidate for one-time binding. +If the expression will not change once set, it is a candidate for one-time binding. Here are three example cases. When interpolating text or attributes: