`
+})
+export class SizerComponent {
+ @Input() size: number;
+ @Output() sizeChange = new EventEmitter();
+
+ dec() { this.resize(-1); }
+ inc() { this.resize(+1); }
+
+ resize(delta: number) {
+ const size = +this.size + delta;
+ this.size = Math.min(40, Math.max(8, size));
+ this.sizeChange.emit(this.size);
+ }
+}
diff --git a/public/docs/ts/latest/guide/change-log.jade b/public/docs/ts/latest/guide/change-log.jade
index 637f604ea4..314875496c 100644
--- a/public/docs/ts/latest/guide/change-log.jade
+++ b/public/docs/ts/latest/guide/change-log.jade
@@ -7,6 +7,16 @@ block includes
The Angular documentation is a living document with continuous improvements.
This log calls attention to recent significant changes.
+ ## "Template Syntax" explains two-way data binding syntax (2016-10-20)
+ Demonstrates how to two-way data bind to a custom Angular component and
+ re-explains `[(ngModel)]` in terms of the basic `[()]` syntax.
+
+ ## "Router" _preload_ syntax and _:enter_/_:leave_ animations (2016-10-19)
+ The router can lazily _preload_ modules _after_ the app starts and
+ _before_ the user navigates to them for improved perceived performance.
+
+ New `:enter` and `:leave` aliases make animation more natural.
+
## Sync with Angular v.2.1.0 (2016-10-12)
Docs and code samples updated and tested with Angular v.2.1.0
diff --git a/public/docs/ts/latest/guide/template-syntax.jade b/public/docs/ts/latest/guide/template-syntax.jade
index f226d451c0..9956bcf654 100644
--- a/public/docs/ts/latest/guide/template-syntax.jade
+++ b/public/docs/ts/latest/guide/template-syntax.jade
@@ -21,6 +21,7 @@ block includes
* [Property binding](#property-binding)
* [Attribute, class, and style bindings](#other-bindings)
* [Event binding](#event-binding)
+ * [Two-way data binding](#two-way)
* [Two-way data binding with `NgModel`](#ngModel)
* [Built-in directives](#directives)
* [NgClass](#ngClass)
@@ -841,19 +842,64 @@ block style-property-name-dart-diff
and the outer `
`, causing a double save.
+makeExample('template-syntax/ts/app/app.component.html', 'event-binding-propagation')(format=".")
-
+#two-way
+.l-main-section
+:marked
+ ## Two-way binding
+ We often want to both display a data property and update that property when the user makes changes.
+
+ On the element side that takes a combination of setting a specific element property
+ and listening for an element change event.
+
+ Angular offers a special _two-way data binding_ syntax for this purpose, **`[(x)]`**.
+ The `[(x)]` syntax combines the brackets
+ of _Property Binding_, `[x]`, with the parentheses of _Event Binding_, `(x)`.
+.callout.is-important
+ header [( )] = banana in a box
+ :marked
+ Visualize a *banana in a box* to remember that the parentheses go _inside_ the brackets.
+:marked
+ The `[(x)]` syntax is easy to demonstrate when the element has a settable property called `x`
+ and a corresponding event named `xChange`.
+ Here's a `SizerComponent` that fits the pattern.
+ It has a `size` value property and a companion `sizeChange` event:
++makeExample('template-syntax/ts/app/sizer.component.ts', null, 'app/sizer.component.ts')
+:marked
+ The initial `size` is an input value from a property binding.
+ Clicking the buttons increases or decreases the `size`, within min/max values constraints,
+ and then raises (_emits_) the `sizeChange` event with the adjusted size.
+
+ Here's an example in which the `AppComponent.fontSize` is two-way bound to the `SizerComponent`:
++makeExample('template-syntax/ts/app/app.component.html', 'two-way-1')(format=".")
+:marked
+ The `AppComponent.fontSize` establishes the initial `SizerComponent.size` value.
+ Clicking the buttons updates the `AppComponent.fontSize` via the two-way binding.
+ The revised `AppComponent.fontSize` value flows through to the _style_ binding, making the displayed text bigger or smaller.
+ Try it in the live example.
+
+ The two-way binding syntax is really just syntactic sugar for a _property_ binding and an _event_ binding.
+ Angular _desugars_ the `SizerComponent` binding into this:
++makeExample('template-syntax/ts/app/app.component.html', 'two-way-2')(format=".")
+:marked
+ The `$event` variable contains the payload of the `SizerComponent.sizeChange` event.
+ Angular assigns the `$event` value to the `AppComponent.fontSize` when the user clicks the buttons.
+
+ Clearly the two-way binding syntax is a great convenience compared to separate property and event bindings.
+
+ We'd like to use two-way binding with HTML form elements like `` and `