-
Notifications
You must be signed in to change notification settings - Fork 876
Copy edits to User Input chapter of Guide. #2397
Conversation
- Add some more space to the right on desktop - Remove `text-decoration` - Use correct `line-height` for the icon
Footer logo was overflowing at ~960px wide viewport. Added `background-size: contain` (shorthand), and `max-width: 100%` to contain wrapper, and background image within grid.
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
angular@69ae63c changed `public/docs/_examples/webpack/ts/config/webpack.common.js` and `public/docs/_examples/webpack/ts/config/webpack.test.js` and replaced `ts` with `awesome-typescript-loader`. So we can remove `"ts-loader": "^0.8.1",` from the `public/docs/_examples/webpack/ts/package.webpack.json`.
…ngular#2342) Add missing app.module.js source example in Basics > Forms dev guide - File is missing for JavaScript, but present for TypeScript
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay, your changes are looking good. I have some feedback—some of which is very similar to feedback I gave Kapunahele, so I'd like her to review this, too.
@kapunahelewong could you please work with Jessica to make sure that (1) your work is consistent and (2) common issues are in the checklist? Thanks!
In the meantime, I'll try to build this to see what it looks like.
|
||
When writing a binding we must be aware of a template statement's **execution context**. | ||
NOTE: A [template statement](./template-syntax.html#template-statements) is a subset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not how we format notes. You should be able to find an example to follow by grepping other .jade files for "Note:".
+makeExample('user-input/ts/app/keyup.components.ts', 'key-up-component-1-template', 'app/keyup.components.ts (template v.1)')(format=".") | ||
:marked | ||
Angular makes an event object available in the **`$event`** variable, | ||
which we pass to the component's `onKey()` method. | ||
The user data we want is in that variable somewhere. | ||
which it passes to the component's `onKey()` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Angular doesn't pass it, our code does. Maybe:
which the code passes as a parameter to ...
to display the accumulating `values` property back on screen. | ||
The `onKey()` component method extracts the user's input | ||
from the event object, adding that input to the list of user data that is accumulating in the component's `values` property. | ||
[Interpolation](./template-syntax.html#interpolation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interpolation doesn't display it, it's how we make it be displayed. Um... maybe:
The code uses interpolation to ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the interpolation displays the accumulating
values
property.
No need for "back onto the screen".
+makeExample('user-input/ts/app/keyup.components.ts', 'key-up-component-1-class', 'app/keyup.components.ts (class v.1 - strongly typed )')(format=".") | ||
:marked | ||
<br>Strong typing reveals a serious problem with passing a DOM event into the method: | ||
too much awareness of template details, too little separation of concerns. | ||
|
||
We'll address this problem in our next try at processing user keystrokes. | ||
You'll address this problem in our next try at processing user keystrokes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grep for "our", replace with "your" or "the" or whatever you deem appropriate.
(grep for "we", while you're at it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And "let's" and "us"
@@ -37,27 +40,27 @@ include ../_util-fns | |||
.l-main-section | |||
:marked | |||
## Get user input from the $event object | |||
We can bind to all kinds of events. Let's bind to the keyup event of an input box and replay | |||
You can bind to all kinds of events. In this case, you'll bind to the keyup event of an input box and replay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page has a lot of "will/'ll" in it, which is counter to our style... I think our editor gave up on doing the kind of rewrite it'd take to eradicate it, but you should feel free to go further (as long as doing so doesn't make the text unfriendly or hard to read).
We're binding to the number 0, the shortest statement we can think of. | ||
That is all it takes to keep Angular happy. We said it would be clever! | ||
By binding the `keyup` event | ||
to the number 0, the shortest statement we can think of, the statement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to avoid "we"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the shortest statement imaginable,
Our previous example won't transfer the current state of the input box if the user mouses away and clicks | ||
elsewhere on the page. We update the component's `values` property only when the user presses Enter | ||
If the user mouses away and clicks elsewhere on the page, | ||
the previous example won't transfer the current state of the input box. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't -> doesn't
elsewhere on the page. We update the component's `values` property only when the user presses Enter | ||
If the user mouses away and clicks elsewhere on the page, | ||
the previous example won't transfer the current state of the input box. | ||
You update the component's `values` property only when the user presses Enter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rewrite this to avoid "You" and be more accurate. Maybe:
The component's values
property updates only when...
|
||
+makeExample('user-input/ts/app/keyup.components.ts', 'key-up-component-4' ,'app/keyup.components.ts (v4)')(format=".") | ||
|
||
.l-main-section | ||
:marked | ||
## Put it all together | ||
We learned how to [display data](./displaying-data.html) in the previous chapter. | ||
We've acquired a small arsenal of event binding techniques in this chapter. | ||
The previous chapter showed how to [display data](./displaying-data.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chapter -> page
(global)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kwalrath We've been consistently calling these things "chapters". When did they become "pages"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wardbell We started that when we switched to the new style guide. I don't remember the history of the decision (Naomi might), but it's in the checklist. I've added it to the word list.
Instead, we grab the input box *value* and pass *that* to `addHero`. | ||
The component knows nothing about HTML or the DOM, which is the way we like it. | ||
Instead of passing the `newHero` into the component's `addHero` method, | ||
grab the input box *value* and pass *that* to `addHero`. | ||
|
||
### Keep template statements simple | ||
We bound `(blur)` to *two* JavaScript statements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We -> (rewrite)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the section that follows, there are lots of "we" and some sentences similar to this one: "The second statement exists for a good reason" that could be cut or minimized.
This paragraph, "Although the example works, we are rightly wary of JavaScript in HTML. Template statements are powerful. We're supposed to use them responsibly. Complex JavaScript in HTML is irresponsible" and "Should we reconsider our reluctance to pass the input box into the component?", could be reworked.
How about something along these lines:
"This example works and is fine for a demonstration, but a better practice is to separate the JavaScript and HTML. Refactor using NgModel as covered in the Forms page."
I signed it! |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
1 similar comment
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
* docs: fix {ts,dart,js}/latest/_data.json Fixes angular#2384. Fixes angular#2385. * post-review updates Addressing angular#2407.
An initial multilang cleanup for ng2.io
No net effect on the generated docs. Preparatory work for ng2.io.
…r#2389) ng2.io preparatory work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like what you've done. Please incorporate (or improve upon) these suggestions and we can quickly move this PR into production.
The `(click)`, to the left of the equals sign, identifies the button's click event as the **target of the binding**. | ||
The text in quotes, to the right of the equals sign, | ||
is the **template statement**, which responds | ||
respond to the click event by calling the component's `onClickMe` method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"responds respond" ?
@@ -37,27 +40,27 @@ include ../_util-fns | |||
.l-main-section | |||
:marked | |||
## Get user input from the $event object | |||
We can bind to all kinds of events. Let's bind to the keyup event of an input box and replay | |||
You can bind to all kinds of events. In this case, you'll bind to the keyup event of an input box and replay |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. "In this case, bind to"
what the user types back onto the screen. | ||
|
||
This time we'll (1) listen to an event and (2) grab the user's input. | ||
This time, you'll listen to an event and grab the user's input. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The imperative mood can help here and many places, don't you think.
As in "This time, listen to an event"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem with using imperative here is that the reader might think that they're being ordered to do something (which they don't know yet how to do yet). This is the one case where future tense (and possibly even "let's") might be the way to go.
[`HTMLInputElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement), which | ||
has a `value` property that contains our user input data. | ||
has a `value` property containing the user input data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious about the penchant for the present participle. Is "containing the" really better than "that contains the"?
This is a genuine uncertainty on my part. Maybe it's a matter of mixing the two forms so that neither dominates and tires the ear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why, either. They seemed equivalent to me. I can ask the editor to explain.
to display the accumulating `values` property back on screen. | ||
The `onKey()` component method extracts the user's input | ||
from the event object, adding that input to the list of user data that is accumulating in the component's `values` property. | ||
[Interpolation](./template-syntax.html#interpolation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the interpolation displays the accumulating
values
property.
No need for "back onto the screen".
|
||
Angular can filter the key events for us. Angular has a special syntax for keyboard events. | ||
We can listen for just the Enter key by binding to Angular's `keyup.enter` pseudo-event. | ||
However, you can listen for just the Enter key by binding to Angular's `keyup.enter` pseudo-event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep the reason for the keyup.enter
alternative. How about this?
Sometimes only the Enter key matters because it signals that the user has finished typing.
The event handler could examine every `$event.keyCode` and pounce on the Enter key.
But there's an easier way: bind to the `keyup.enter` pseudo-event and Angular will call the
handler for that key alone.
+makeExample('user-input/ts/app/keyup.components.ts', 'key-up-component-3' ,'app/keyup.components.ts (v3)')(format=".")
.l-sub-section
:marked
In this example, the data binding expression handles the event. It's a better practice to
minimize JavaScript in HTML and move this code into the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that the reason for the keyup.enter alternative should be in there (as succinctly as possible, while still being clear).
while the focus is inside the input box. | ||
|
||
Let's fix that by listening to the input box's blur event as well. | ||
To fix that, listen to the input box's blur event as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's crisp up the entire intro. What do you think of this:
In the previous example, the current state of the input box is lost if the user mouses away and clicks elsewhere on the page without first pressing Enter.
To fix that, listen for both the Enter key and the blur event.
|
||
+makeExample('user-input/ts/app/keyup.components.ts', 'key-up-component-4' ,'app/keyup.components.ts (v4)')(format=".") | ||
|
||
.l-main-section | ||
:marked | ||
## Put it all together | ||
We learned how to [display data](./displaying-data.html) in the previous chapter. | ||
We've acquired a small arsenal of event binding techniques in this chapter. | ||
The previous chapter showed how to [display data](./displaying-data.html). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kwalrath We've been consistently calling these things "chapters". When did they become "pages"?
|
||
There should be a better third way. And there is, as we'll see when we learn about `NgModel` in the [Forms](forms.html) chapter. | ||
Although the example *works*, it makes use of JavaScript in HTML, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the example works, it relies on JavaScript in the HTML. That's a bad practice. Move the JavaScript to the component class.
Angular has a two-way binding called `NgModel`, which we'll learn about | ||
in the `Forms` chapter. | ||
Angular has a two-way binding called `NgModel`, which is explained in | ||
the `Forms` chapter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have mastered the basic primitives for responding to user input and gestures.
They quickly become verbose and clumsy when handling large amounts of user input. Two-way data binding is a more elegant and compact way to move values between data entry fields and model properties. The next chapter, "Forms", explains how to write two-way bindings with
NgModel
.
We can't merge until you have a CLA that Github recognizes. Normally I take care of that by adding you to our IdeaBlade google group (you're covered under our CLA). But that isn't working here because you're github contributions are in the name of "niceredfrog" which doesn't have an associated email address. I can enroll you in our group but only with a github-recognized email address. I've sent you an invitation to join that group using the email associated with your commits. You may have to update the niceredfrog profile with that address. If you don't want to do that (not clear why; anyone looking at your commits can see the email address as I did), you can sign your own personal CLA. |
Travis reports that this jade doc is broken. Confirmed by running The cause in this case is a blank line after |
.htm => .html
The `end_of_line` setting causes issues on Windows machines that have `autocrlf` set to true (the default): https://git-scm.com/book/tr/v2/Customizing-Git-Git-Configuration#Formatting-and-Whitespace
Confirm.
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.— |
* added example of feature module pre-loading * added transition aliases for route animations
- gulp task: don’t copy over internal libraries. - Adjust anchor hrefs rather than use `<base href>` in generated API pages. The net effect is the same.
* chore: update examples to @types * fix toh-6 aot and add types link
Technically 'nestled' still makes sense in this context, but is a little too Christmas-y! - I assume you meant 'nested' :P
No description provided.