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

Commit 16848fc

Browse files
chalinwardbell
authored andcommitted
docs(toh-2/ts): copyedits
closes #1622
1 parent 59408b1 commit 16848fc

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

public/docs/_examples/toh-2/ts/app/app.component.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// #docregion pt2
1+
// #docregion
22
import { Component } from '@angular/core';
33

44
export class Hero {
@@ -42,7 +42,7 @@ const HEROES: Hero[] = [
4242
</div>
4343
</div>
4444
`,
45-
// #docregion styles-1
45+
// #docregion styles
4646
styles: [`
4747
.selected {
4848
background-color: #CFD8DC !important;
@@ -92,18 +92,16 @@ const HEROES: Hero[] = [
9292
border-radius: 4px 0 0 4px;
9393
}
9494
`]
95-
// #enddocregion styles-1
95+
// #enddocregion styles
9696
})
9797
export class AppComponent {
9898
title = 'Tour of Heroes';
9999
heroes = HEROES;
100-
// #docregion selected-hero-1
100+
// #docregion selected-hero
101101
selectedHero: Hero;
102-
// #enddocregion selected-hero-1
102+
// #enddocregion selected-hero
103103

104-
// #docregion on-select-1
104+
// #docregion on-select
105105
onSelect(hero: Hero) { this.selectedHero = hero; }
106-
// #enddocregion on-select-1
106+
// #enddocregion on-select
107107
}
108-
109-
// #enddocregion pt2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
// #docregion pt1
21
import { bootstrap } from '@angular/platform-browser-dynamic';
32

43
import { AppComponent } from './app.component';
54

65
bootstrap(AppComponent);
7-
// #enddocregion pt1

public/docs/ts/latest/tutorial/toh-pt2.jade

+19-20
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ code-example(language="bash").
5050
### Creating heroes
5151
Let’s create an array of ten heroes at the bottom of `app.component.ts`.
5252

53-
+makeExample('toh-2/ts/app/app.component.ts', 'hero-array', 'app.component.ts (Hero array)')
53+
+makeExample('toh-2/ts/app/app.component.ts', 'hero-array', 'app.component.ts (hero array)')
5454

5555
:marked
5656
The `HEROES` array is of type `Hero`, the class defined in part one,
@@ -59,9 +59,9 @@ code-example(language="bash").
5959
first and display mock heroes.
6060

6161
### Exposing heroes
62-
Let’s create a property in `AppComponent` that exposes the heroes for binding.
62+
Let’s create a public property in `AppComponent` that exposes the heroes for binding.
6363

64-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'hero-array-1', 'app.component.ts (Hero array property)')
64+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'hero-array-1', 'app.component.ts (hero array property)')
6565

6666
:marked
6767
We did not have to define the `heroes` type. TypeScript can infer it from the `HEROES` array.
@@ -76,7 +76,7 @@ code-example(language="bash").
7676
Our component has `heroes`. Let’s create an unordered list in our template to display them.
7777
We’ll insert the following chunk of HTML below the title and above the hero details.
7878

79-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-template-1', 'app.component.ts (Heroes template)')
79+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-template-1', 'app.component.ts (heroes template)')
8080

8181
:marked
8282
Now we have a template that we can fill with our heroes.
@@ -107,7 +107,7 @@ code-example(language="bash").
107107
“*take each hero in the `heroes` array, store it in the local `hero` variable,
108108
and make it available to the corresponding template instance*”.
109109

110-
The `let` keyword before "hero" identifies the `hero` as a template input variable.
110+
The `let` keyword before "hero" identifies `hero` as a template input variable.
111111
We can reference this variable within the template to access a hero’s properties.
112112

113113
Learn more about `ngFor` and template input variables in the
@@ -130,21 +130,20 @@ code-example(language="bash").
130130
Let’s add some styles to our component by setting the `styles` property on the `@Component` decorator
131131
to the following CSS classes:
132132

133-
+makeExample('toh-2/ts/app/app.component.ts', 'styles-1', 'app.component.ts (Styling)')
133+
+makeExample('toh-2/ts/app/app.component.ts', 'styles', 'app.component.ts (styles)')(format=".")
134134

135135
:marked
136136
Notice that we again use the back-tick notation for multi-line strings.
137137

138+
That's a lot of styles! We can put them inline as shown here, or we can move them out to their own file which will make it easier to code our component.
139+
We'll do this in a later chapter. For now let's keep rolling.
140+
138141
When we assign styles to a component they are scoped to that specific component.
139142
Our styles will only apply to our `AppComponent` and won't "leak" to the outer HTML.
140143

141144
Our template for displaying the heroes should now look like this:
142145

143-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-styled', 'app.component.ts (Styled heroes)')
144-
145-
:marked
146-
That's a lot of styles! We can put them inline as shown here, or we can move them out to their own file which will make it easier to code our component.
147-
We'll do this in a later chapter. For now let's keep rolling.
146+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-styled', 'app.component.ts (styled heroes)')
148147

149148
.l-main-section
150149
:marked
@@ -160,7 +159,7 @@ code-example(language="bash").
160159
### Click event
161160
We modify the `<li>` by inserting an Angular event binding to its click event.
162161

163-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-click', 'app.component.ts (Capturing the click event)')
162+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-click', 'app.component.ts (template excerpt)')
164163

165164
:marked
166165
Focus on the event binding
@@ -190,21 +189,21 @@ code-example(language="bash").
190189
We no longer need the static `hero` property of the `AppComponent`.
191190
**Replace** it with this simple `selectedHero` property:
192191

193-
+makeExample('toh-2/ts/app/app.component.ts', 'selected-hero-1', 'app.component.ts (selectedHero)')
192+
+makeExample('toh-2/ts/app/app.component.ts', 'selected-hero', 'app.component.ts (selectedHero)')
194193

195194
:marked
196195
We’ve decided that none of the heroes should be selected before the user picks a hero so
197196
we won’t initialize the `selectedHero` as we were doing with `hero`.
198197

199198
Now **add an `onSelect` method** that sets the `selectedHero` property to the `hero` the user clicked.
200-
+makeExample('toh-2/ts/app/app.component.ts', 'on-select-1', 'app.component.ts (onSelect)')
199+
+makeExample('toh-2/ts/app/app.component.ts', 'on-select', 'app.component.ts (onSelect)')
201200

202201
:marked
203202
We will be showing the selected hero's details in our template.
204203
At the moment, it is still referring to the old `hero` property.
205204
Let’s fix the template to bind to the new `selectedHero` property.
206205

207-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-details', 'app.component.ts (Binding to the selectedHero\'s name)')
206+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-details', 'app.component.ts (template excerpt)')
208207
:marked
209208
### Hide the empty detail with ngIf
210209

@@ -266,16 +265,16 @@ code-example(language="bash").
266265

267266
The key is the name of the CSS class (`selected`). The value is `true` if the two heroes match and `false` otherwise.
268267
We’re saying “*apply the `selected` class if the heroes match, remove it if they don’t*”.
269-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-1', 'app.component.ts (Setting the CSS class)')(format=".")
268+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-1', 'app.component.ts (setting the CSS class)')(format=".")
270269
:marked
271270
Notice in the template that the `class.selected` is surrounded in square brackets (`[]`).
272-
This is the syntax for a Property Binding, a binding in which data flows one way
271+
This is the syntax for a **property binding**, a binding in which data flows one way
273272
from the data source (the expression `hero === selectedHero`) to a property of `class`.
274-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-2', 'app.component.ts (Styling each hero)')(format=".")
273+
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-2', 'app.component.ts (styling each hero)')(format=".")
275274

276275
.l-sub-section
277276
:marked
278-
Learn more about [Property Binding](../guide/template-syntax.html#property-binding)
277+
Learn more about [property bindings](../guide/template-syntax.html#property-binding)
279278
in the Template Syntax chapter.
280279

281280
:marked
@@ -290,7 +289,7 @@ code-example(language="bash").
290289

291290
Here's the complete `app.component.ts` as it stands now:
292291

293-
+makeExample('toh-2/ts/app/app.component.ts', 'pt2', 'app.component.ts')
292+
+makeExample('toh-2/ts/app/app.component.ts', '', 'app.component.ts')
294293

295294
.l-main-section
296295
:marked

0 commit comments

Comments
 (0)