@@ -775,7 +775,7 @@ block style-property-name-dart-diff
775
775
776
776
<a id="eventemitter"></a>
777
777
<a id="custom-event"></a>
778
- ### Custom events with EventEmitter
778
+ ### Custom events with * EventEmitter*
779
779
780
780
Directives typically raise custom events with an Angular [EventEmitter](../api/core/index/EventEmitter-class.html).
781
781
The directive creates an `EventEmitter` and exposes it as a property.
@@ -860,7 +860,7 @@ block style-property-name-dart-diff
860
860
:marked
861
861
The `[(x)]` syntax is easy to demonstrate when the element has a settable property called `x`
862
862
and a corresponding event named `xChange`.
863
- Here's a `MySizerComponent ` that fits the pattern.
863
+ Here's a `SizerComponent ` that fits the pattern.
864
864
It has a `size` value property and a companion `sizeChange` event:
865
865
866
866
+ makeExample('app/my-sizer.component.ts' )
@@ -870,23 +870,23 @@ block style-property-name-dart-diff
870
870
Clicking the buttons increases or decreases the `size`, within min/max values constraints,
871
871
and then raises (_emits_) the `sizeChange` event with the adjusted size.
872
872
873
- Here's an example in which the `AppComponent.fontSizePx` is two-way bound to the `MySizerComponent `:
873
+ Here's an example in which the `AppComponent.fontSizePx` is two-way bound to the `SizerComponent `:
874
874
875
875
+ makeExcerpt('app/app.component.html' , 'two-way-1' , '' )
876
876
877
877
:marked
878
- The `AppComponent.fontSizePx` establishes the initial `MySizerComponent .size` value.
878
+ The `AppComponent.fontSizePx` establishes the initial `SizerComponent .size` value.
879
879
Clicking the buttons updates the `AppComponent.fontSizePx` via the two-way binding.
880
880
The revised `AppComponent.fontSizePx` value flows through to the _style_ binding, making the displayed text bigger or smaller.
881
881
Try it in the <live-example></live-example>.
882
882
883
883
The two-way binding syntax is really just syntactic sugar for a _property_ binding and an _event_ binding.
884
- Angular _desugars_ the `MySizerComponent ` binding into this:
884
+ Angular _desugars_ the `SizerComponent ` binding into this:
885
885
886
886
+ makeExcerpt('app/app.component.html' , 'two-way-2' , '' )
887
887
888
888
:marked
889
- The `$event` variable contains the payload of the `MySizerComponent .sizeChange` event.
889
+ The `$event` variable contains the payload of the `SizerComponent .sizeChange` event.
890
890
Angular assigns the `$event` value to the `AppComponent.fontSizePx` when the user clicks the buttons.
891
891
892
892
Clearly the two-way binding syntax is a great convenience compared to separate property and event bindings.
0 commit comments