Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 209f4f3

Browse files
phollypetebacondarwin
authored andcommitted
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
1 parent 5d68c76 commit 209f4f3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docs/content/guide/expression.ngdoc

+10-6
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ Angular expressions are like JavaScript expressions with the following differenc
2828

2929
* **No Control Flow Statements:** You cannot use the following in an Angular expression:
3030
conditionals, loops, or exceptions.
31-
31+
3232
* **No Function Declarations:** You cannot declare functions in an Angular expression,
3333
even inside `ng-init` directive.
34-
35-
* **No RegExp Creation With Literal Notation:** You cannot create regular expressions
34+
35+
* **No RegExp Creation With Literal Notation:** You cannot create regular expressions
3636
in an Angular expression.
37-
37+
3838
* **No Comma And Void Operators:** You cannot use `,` or `void` in an Angular expression.
3939

4040
* **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.
175175
## No function declarations or RegExp creation with literal notation
176176

177177
You can't declare functions or create regular expressions from within AngularJS expressions. This is
178-
to avoid complex model transformation logic inside templates. Such logic is better placed in a
178+
to avoid complex model transformation logic inside templates. Such logic is better placed in a
179179
controller or in a dedicated filter where it can be tested properly.
180180

181181
## `$event`
@@ -303,10 +303,14 @@ then the expression is not fulfilled and will remain watched.
303303
keep dirty-checking the watch in the future digest loops by following the same
304304
algorithm starting from step 1
305305

306+
#### Special case for object literals
307+
308+
Unlike simple values, object-literals are watched until every key is defined.
309+
See http://www.bennadel.com/blog/2760-one-time-data-bindings-for-object-literal-expressions-in-angularjs-1-3.htm
306310

307311
### How to benefit from one-time binding
308312

309-
If the expression will not change once set, it is a candidate for one-time binding.
313+
If the expression will not change once set, it is a candidate for one-time binding.
310314
Here are three example cases.
311315

312316
When interpolating text or attributes:

0 commit comments

Comments
 (0)