Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 32ac619

Browse files
pfryerdakwalrath
authored andcommitted
Uwaterloo 210J pfryerda edits (#1968)
* template-syntax - removed word redundancies, consistent bolding rather than italics * Some (not all) changes from PR. * remaining changes from pull request
1 parent 59f6ebe commit 32ac619

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

public/docs/ts/latest/guide/template-syntax.jade

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -711,12 +711,12 @@ block style-property-name-dart-diff
711711
712712
.l-main-section
713713
:marked
714-
## Event Binding
715-
The bindings we’ve met so far flow data in one direction: *from the component to an element*.
714+
## Event binding
715+
The bindings we’ve met so far flow data in one direction: **from a component to an element**.
716716

717717
Users don’t just stare at the screen. They enter text into input boxes. They pick items from lists.
718718
They click buttons. Such user actions may result in a flow of data in the opposite direction:
719-
*from an element to the component*.
719+
**from an element to a component**.
720720

721721
The only way to know about a user action is to listen for certain events such as
722722
keystrokes, mouse movements, clicks, and touches.
@@ -728,12 +728,12 @@ block style-property-name-dart-diff
728728
the component's `onSave()` method whenever a click occurs:
729729
+makeExample('template-syntax/ts/app/app.component.html', 'event-binding-1')(format=".")
730730
:marked
731-
### Target Event
732-
A **name between enclosing parentheses** — for example, `(click)` —
731+
### Target event
732+
A **name between parentheses** — for example, `(click)` —
733733
identifies the target event. In the following example, the target is the button’s click event.
734734
+makeExample('template-syntax/ts/app/app.component.html', 'event-binding-1')(format=".")
735735
:marked
736-
Some people prefer the `on-` prefix alternative, known as the *canonical form*:
736+
Some people prefer the `on-` prefix alternative, known as the **canonical form**:
737737
+makeExample('template-syntax/ts/app/app.component.html', 'event-binding-2')(format=".")
738738
:marked
739739
Element events may be the more common targets, but Angular looks first to see if the name matches an event property
@@ -742,47 +742,46 @@ block style-property-name-dart-diff
742742

743743
.l-sub-section
744744
:marked
745-
The `myClick` directive is further described below in the section
746-
on [Aliasing input/output properties](#aliasing-io).
745+
The `myClick` directive is further described in the section
746+
on [aliasing input/output properties](#aliasing-io).
747747

748748
:marked
749-
If the name fails to match an element event or an output property of a known directive,
749+
If the name fails to match element event or output property of a known directive,
750750
Angular reports an “unknown directive” error.
751751

752752
### *$event* and event handling statements
753753
In an event binding, Angular sets up an event handler for the target event.
754754

755755
When the event is raised, the handler executes the template statement.
756-
The template statement typically involves a receiver that wants to do something
757-
in response to the event, such as take a value from the HTML control and store it
758-
in a model.
756+
The template statement typically involves a receiver, which performs an action
757+
in response to the event, such as storing a value from the HTML control
758+
into a model.
759759

760760
The binding conveys information about the event, including data values, through
761761
an **event object named `$event`**.
762762

763-
The shape of the event object is determined by the target event itself.
764-
If the target event is a native DOM element event, the `$event` is a
763+
The shape of the event object is determined by the target event.
764+
If the target event is a native DOM element event, then `$event` is a
765765
[DOM event object]( https://developer.mozilla.org/en-US/docs/Web/Events),
766766
with properties such as `target` and `target.value`.
767767

768768
Consider this example:
769769
+makeExample('template-syntax/ts/app/app.component.html', 'without-NgModel')(format=".")
770770
:marked
771-
We’re binding the input box `value` to a `firstName` property, and we’re listening for changes by binding to the input boxs `input` event.
771+
This code sets the input box `value` property by binding to the `firstName` property. To listen for changes to the value, the code binds to the input box's `input` event.
772772
When the user makes changes, the `input` event is raised, and the binding executes the statement within a context that includes the DOM event object, `$event`.
773773

774-
To update the `firstName` property, we must get the changed text by following
775-
the path `$event.target.value`.
774+
To update the `firstName` property, the changed text is retrieved by following the path `$event.target.value`.
776775

777-
If the event belongs to a directive (remember: components are directives), `$event` has whatever shape the directive chose to produce.
776+
If the event belongs to a directive (recall that components are directives), `$event` has whatever shape the directive decides to produce.
778777

779778
<a id="eventemitter"></a>
780779
<a id="custom-event"></a>
781780
### Custom Events with EventEmitter
782781

783782
Directives typically raise custom events with an Angular [EventEmitter](../api/core/index/EventEmitter-class.html).
784-
A directive creates an `EventEmitter` and exposes it as a property.
785-
The directive calls `EventEmitter.emit(payload)` to fire an event, passing in a message payload that can be anything.
783+
The directive creates an `EventEmitter` and exposes it as a property.
784+
The directives calls `EventEmitter.emit(payload)` to fire an event, passing in a message payload, which can be anything.
786785
Parent directives listen for the event by binding to this property and accessing the payload through the `$event` object.
787786

788787
Consider a `HeroDetailComponent` that presents hero information and responds to user actions.
@@ -797,8 +796,8 @@ block style-property-name-dart-diff
797796

798797
:marked
799798
The component defines a `deleteRequest` property that returns an `EventEmitter`.
800-
When the user clicks *delete*, the component invokes the `delete()` method
801-
which tells the `EventEmitter` to emit a `Hero` object.
799+
When the user clicks *delete*, the component invokes the `delete()` method,
800+
telling the `EventEmitter` to emit a `Hero` object.
802801

803802
Now imagine a hosting parent component that binds to the `HeroDetailComponent`'s `deleteRequest` event.
804803

@@ -810,12 +809,11 @@ block style-property-name-dart-diff
810809

811810
### Template statements have side effects
812811
The `deleteHero` method has a side effect: it deletes a hero.
813-
Template statement side effects are not just OK, they are expected.
812+
Template statement side effects are not just OK, but expected.
814813

815814
Deleting the hero updates the model, perhaps triggering other changes
816815
including queries and saves to a remote server.
817816
These changes percolate through the system and are ultimately displayed in this and other views.
818-
It's all good.
819817

820818
//
821819
:marked

0 commit comments

Comments
 (0)