@@ -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,33 +860,33 @@ 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
- + makeExample('app/my- sizer.component.ts' )
866
+ + makeExample('app/sizer.component.ts' )
867
867
868
868
:marked
869
869
The initial `size` is an input value from a property binding.
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.
@@ -1423,7 +1423,7 @@ h3#aliasing-io Aliasing input/output properties
1423
1423
Directive consumers expect to bind to the name of the directive.
1424
1424
For example, when we apply a directive with a `myClick` selector to a `<div>` tag,
1425
1425
we expect to bind to an event property that is also called `myClick`.
1426
- + makeExample('template-syntax/ts/app/app.component.html' , 'my-click ' )( format ="." )
1426
+ + makeExample('template-syntax/ts/app/app.component.html' , 'myClick ' )( format ="." )
1427
1427
:marked
1428
1428
However, the directive name is often a poor choice for the name of a property within the directive class.
1429
1429
The directive name rarely describes what the property does.
@@ -1436,14 +1436,14 @@ h3#aliasing-io Aliasing input/output properties
1436
1436
1437
1437
We can specify the alias for the property name by passing it into the input/output decorator like this:
1438
1438
1439
- + makeExample('template-syntax/ts/app/my- click.directive.ts' , 'my-click- output-1 ' )( format ="." )
1439
+ + makeExample('template-syntax/ts/app/click.directive.ts' , 'output-myClick ' )( format ="." )
1440
1440
1441
1441
.l-sub-section
1442
1442
:marked
1443
1443
We can also alias property names in the `inputs` and `outputs` #{_array}s.
1444
1444
We write a colon-delimited (`:`) string with
1445
1445
the directive property name on the *left* and the public alias on the *right*:
1446
- + makeExample('template-syntax/ts/app/my- click.directive.ts' , 'my-click- output-2 ' )( format ="." )
1446
+ + makeExample('template-syntax/ts/app/click.directive.ts' , 'output-myClick2 ' )( format ="." )
1447
1447
1448
1448
<a id =" expression-operators" ></a >
1449
1449
.l-main-section
0 commit comments