You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
The `(click)` to the left of the equal sign identifies the button's click event as the **target of the binding**.
22
-
The text within quotes on the right is the **template expression** in which we
23
-
respond to the click event by calling the component's `onClickMe` method. A template expression <!-- PENDING: link to ./template-syntax.html#template-expressions --> is a subset
24
-
of Dart with a few added tricks.
23
+
The text within quotes on the right is the **template statement** in which we
24
+
respond to the click event by calling the component's `onClickMe` method. A template statement <!-- PENDING: link to ./template-syntax.html#template-statements --> is a subset
25
+
of Dart with restrictions and a few added tricks.
25
26
26
-
When writing a binding we must be aware of a template expression's **execution context**.
27
-
The identifiers appearing within an expression belong to a specific context object.
27
+
When writing a binding we must be aware of a template statement's **execution context**.
28
+
The identifiers appearing within a statement belong to a specific context object.
28
29
That object is usually the Angular component that controls the template ... which it definitely is
29
30
in this case because that snippet of HTML belongs to the following component:
30
31
@@ -121,8 +122,8 @@ figure.image-display
121
122
Angular only updates the bindings (and therefore the screen)
122
123
if we do something in response to asynchronous events such as keystrokes.
123
124
124
-
That's why we bind the `keyup` event to an expression that does ... well, nothing.
125
-
We're binding to the number 0, the shortest expression we can think of.
125
+
That's why we bind the `keyup` event to a statement that does ... well, nothing.
126
+
We're binding to the number 0, the shortest statement we can think of.
126
127
That is all it takes to keep Angular happy. We said it would be clever!
127
128
:marked
128
129
That local template variable is intriguing. It's clearly easier to get to the textbox with that
@@ -140,14 +141,14 @@ figure.image-display
140
141
## Key event filtering (with `key.enter`)
141
142
Perhaps we don't care about every keystroke.
142
143
Maybe we're only interested in the input box value when the user presses Enter, and we'd like to ignore all other keys.
143
-
When we bind to the `(keyup)` event, our event handling expression hears *every keystroke*.
144
+
When we bind to the `(keyup)` event, our event handling statement hears *every keystroke*.
144
145
We could filter the keys first, examining every `$event.keyCode`, and update the `values` property only if the key is Enter.
145
146
146
147
Angular can filter the key events for us. Angular has a special syntax for keyboard events.
147
148
We can listen for just the Enter key by binding to Angular's `keyup.enter` pseudo-event.
148
149
149
150
Only then do we update the component's `values` property. (In this example,
150
-
the update happens inside the event expression. A better practice
151
+
the update happens inside the event binding statement. A better practice
151
152
would be to put the update code in the component.)
0 commit comments