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

Commit 4fcd3e5

Browse files
committed
docs(toh-2): replace snippets file; indent subsection; add (format='.').
1 parent 25ad010 commit 4fcd3e5

File tree

3 files changed

+38
-37
lines changed

3 files changed

+38
-37
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
// #docregion ng-for
1+
<!-- #docregion ng-for -->
22
<li *ngFor="let hero of heroes">
33
<span class="badge">{{hero.id}}</span> {{hero.name}}
44
</li>
5-
// #enddocregion ng-for
5+
<!-- #enddocregion ng-for -->
66

7-
// #docregion heroes-styled
7+
<!-- #docregion heroes-styled -->
88
<h2>My Heroes</h2>
99
<ul class="heroes">
1010
<li *ngFor="let hero of heroes">
1111
<span class="badge">{{hero.id}}</span> {{hero.name}}
1212
</li>
1313
</ul>
14-
// #enddocregion heroes-styled
14+
<!-- #enddocregion heroes-styled -->
1515

16-
// #docregion selectedHero-click
16+
<!-- #docregion selectedHero-click -->
1717
<li *ngFor="let hero of heroes" (click)="onSelect(hero)">
18-
<span class="badge">{{hero.id}}</span> {{hero.name}}
18+
...
1919
</li>
20-
// #enddocregion selectedHero-click
20+
<!-- #enddocregion selectedHero-click -->
2121

22-
// #docregion selectedHero-details
22+
<!-- #docregion selectedHero-details -->
2323
<h2>{{selectedHero.name}} details!</h2>
2424
<div><label>id: </label>{{selectedHero.id}}</div>
2525
<div>
2626
<label>name: </label>
2727
<input [(ngModel)]="selectedHero.name" placeholder="name"/>
2828
</div>
29-
// #enddocregion selectedHero-details
29+
<!-- #enddocregion selectedHero-details -->
3030

31-
// #docregion ng-if
31+
<!-- #docregion ng-if -->
3232
<div *ngIf="selectedHero">
3333
<h2>{{selectedHero.name}} details!</h2>
3434
<div><label>id: </label>{{selectedHero.id}}</div>
@@ -37,33 +37,33 @@ <h2>{{selectedHero.name}} details!</h2>
3737
<input [(ngModel)]="selectedHero.name" placeholder="name"/>
3838
</div>
3939
</div>
40-
// #enddocregion ng-if
40+
<!-- #enddocregion ng-if -->
4141

42-
// #docregion hero-array-1
42+
<!-- #docregion hero-array-1 -->
4343
heroes = HEROES;
44-
// #enddocregion hero-array-1
44+
<!-- #enddocregion hero-array-1 -->
4545

46-
// #docregion heroes-template-1
46+
<!-- #docregion heroes-template-1 -->
4747
<h2>My Heroes</h2>
4848
<ul class="heroes">
4949
<li>
5050
<!-- each hero goes here -->
5151
</li>
5252
</ul>
53-
// #enddocregion heroes-template-1
53+
<!-- #enddocregion heroes-template-1 -->
5454

55-
// #docregion heroes-ngfor-1
55+
<!-- #docregion heroes-ngfor-1 -->
5656
<li *ngFor="let hero of heroes">
57-
// #enddocregion heroes-ngfor-1
57+
<!-- #enddocregion heroes-ngfor-1 -->
5858

59-
// #docregion class-selected-1
59+
<!-- #docregion class-selected-1 -->
6060
[class.selected]="hero === selectedHero"
61-
// #enddocregion class-selected-1
61+
<!-- #enddocregion class-selected-1 -->
6262

63-
// #docregion class-selected-2
63+
<!-- #docregion class-selected-2 -->
6464
<li *ngFor="let hero of heroes"
6565
[class.selected]="hero === selectedHero"
6666
(click)="onSelect(hero)">
6767
<span class="badge">{{hero.id}}</span> {{hero.name}}
6868
</li>
69-
// #enddocregion class-selected-2
69+
<!-- #enddocregion class-selected-2 -->

public/docs/_examples/toh-2/ts/plnkr.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"description": "Tour of Heroes: Part 2",
33
"files":[
44
"!**/*.d.ts",
5-
"!**/*.js"
5+
"!**/*.js",
6+
"!**/*.[1].*"
67
],
78
"tags": ["tutorial", "tour", "heroes"]
89
}

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

+15-15
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ code-example(language="sh" class="code-shell").
5555
### Expose heroes
5656
Create a public property in `AppComponent` that exposes the heroes for binding.
5757

58-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'hero-array-1', 'app.component.ts (hero array property)')
58+
+makeExample('toh-2/ts/app/app.component.1.html', 'hero-array-1', 'app.component.ts (hero array property)')
5959

6060
:marked
6161
The `heroes` type isn't defined because TypeScript infers it from the `HEROES` array.
6262

6363
.l-sub-section
64-
:marked
65-
The hero data is separated from the class implementation
66-
because ultimately the hero names will come from a data service.
64+
:marked
65+
The hero data is separated from the class implementation
66+
because ultimately the hero names will come from a data service.
6767

6868
:marked
6969
### Display hero names in a template
7070
The component has `heroes`. To display the hero names in an unordered list,
7171
insert the following chunk of HTML below the title and above the hero details.
7272

73-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-template-1', 'app.component.ts (heroes template)')
73+
+makeExample('toh-2/ts/app/app.component.1.html', 'heroes-template-1', 'app.component.ts (heroes template)')(format='.')
7474

7575
:marked
7676
Now you can fill the template with hero names.
@@ -82,7 +82,7 @@ code-example(language="sh" class="code-shell").
8282

8383
Modify the `<li>` tag by adding the built-in directive `*ngFor`.
8484

85-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-ngfor-1', 'app.component.ts (ngFor)')
85+
+makeExample('toh-2/ts/app/app.component.1.html', 'heroes-ngfor-1', 'app.component.ts (ngFor)')
8686

8787
.alert.is-critical
8888
:marked
@@ -116,7 +116,7 @@ code-example(language="sh" class="code-shell").
116116
In the `<li>` tags, add content
117117
that uses the `hero` template variable to display the hero's properties.
118118

119-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'ng-for', 'app.component.ts (ngFor template)')(format=".")
119+
+makeExample('toh-2/ts/app/app.component.1.html', 'ng-for', 'app.component.ts (ngFor template)')(format=".")
120120

121121
:marked
122122
When the browser refreshes, a list of heroes displays.
@@ -127,7 +127,7 @@ code-example(language="sh" class="code-shell").
127127
To add styles to your component, set the `styles` property on the `@Component` decorator
128128
to the following CSS classes:
129129

130-
+makeExample('toh-2/ts/app/app.component.ts', 'styles', 'app.component.ts (styles)')(format=".")
130+
+makeExample('toh-2/ts/app/app.component.ts', 'styles', 'app.component.ts (styles)')
131131

132132
:marked
133133
Notice that again you used the backtick notation for multi-line strings.
@@ -139,7 +139,7 @@ code-example(language="sh" class="code-shell").
139139

140140
The template for displaying heroes should look like this:
141141

142-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'heroes-styled', 'app.component.ts (styled heroes)')
142+
+makeExample('toh-2/ts/app/app.component.1.html', 'heroes-styled', 'app.component.ts (styled heroes)')(format='.')
143143

144144
.l-main-section
145145
:marked
@@ -157,7 +157,7 @@ code-example(language="sh" class="code-shell").
157157
### Add a click event
158158
Modify the `<li>` by inserting an Angular event binding to its click event.
159159

160-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-click', 'app.component.ts (template excerpt)')
160+
+makeExample('toh-2/ts/app/app.component.1.html', 'selectedHero-click', 'app.component.ts (template excerpt)')(format='.')
161161

162162
:marked
163163
Notice the event binding:
@@ -187,13 +187,13 @@ code-example(language="sh" class="code-shell").
187187
you won't initialize the `selectedHero` as you did with `hero`.
188188

189189
Add an `onSelect` method that sets the `selectedHero` property to the `hero` that the user clicks.
190-
+makeExample('toh-2/ts/app/app.component.ts', 'on-select', 'app.component.ts (onSelect)')
190+
+makeExample('toh-2/ts/app/app.component.ts', 'on-select', 'app.component.ts (onSelect)')(format='.')
191191

192192
:marked
193193
At the moment, the template still refers to the old `hero` property.
194194
To change the template to bind to the new `selectedHero` property, update the code as follows:
195195

196-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'selectedHero-details', 'app.component.ts (template excerpt)')
196+
+makeExample('toh-2/ts/app/app.component.1.html', 'selectedHero-details', 'app.component.ts (template excerpt)')(format='.')
197197
:marked
198198
### Hide the empty detail with ngIf
199199

@@ -212,7 +212,7 @@ code-example(language="sh" class="code-shell").
212212
Wrap the HTML hero detail content of your template with a `<div>`.
213213
Then add the `ngIf` built-in directive and set it to the `selectedHero` property of the component.
214214

215-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'ng-if', 'app.component.ts (ngIf)')
215+
+makeExample('toh-2/ts/app/app.component.1.html', 'ng-if', 'app.component.ts (ngIf)')(format='.')
216216

217217
:marked
218218
The list of names displays again in the browser.
@@ -263,15 +263,15 @@ code-example(language="sh" class="code-shell").
263263
You can set the class to an expression that compares the current `selectedHero` to the `hero`.
264264

265265
The key is the name of the CSS class (`selected`). The value is `true` if the two heroes match and `false` if they don't.
266-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-1', 'app.component.ts (setting the CSS class)')(format=".")
266+
+makeExample('toh-2/ts/app/app.component.1.html', 'class-selected-1', 'app.component.ts (setting the CSS class)')(format=".")
267267
:marked
268268
Notice that `class.selected` is surrounded by square brackets (`[]`).
269269
This is the syntax for a *property binding*, in which data flows one way
270270
from the data source (the expression `hero === selectedHero`) to a property of `class`.
271271
// CF: What is the preferred style for introduced terms? In this page I see two: quotes (used in
272272
"master-detail" on line 151 and "structural directives" on line 241) and italics (used in
273273
*property binding* on line 270).
274-
+makeExample('toh-2/ts-snippets/app.component.snippets.pt2.ts', 'class-selected-2', 'app.component.ts (styling each hero)')(format=".")
274+
+makeExample('toh-2/ts/app/app.component.1.html', 'class-selected-2', 'app.component.ts (styling each hero)')(format=".")
275275

276276
.l-sub-section
277277
:marked

0 commit comments

Comments
 (0)