@@ -61,7 +61,7 @@ code-example(language="sh" class="code-shell").
61
61
Create a public property in `AppComponent` that exposes the heroes for binding.
62
62
63
63
64
- + makeExample('toh-2/ts/app/app.component.1.html' , 'hero-array-1' , 'app.component.ts (hero array property)' )
64
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'hero-array-1' , 'app.component.ts (hero array property)' )
65
65
66
66
:marked
67
67
The `heroes` type isn't defined because TypeScript infers it from the `HEROES` array.
@@ -77,7 +77,7 @@ code-example(language="sh" class="code-shell").
77
77
insert the following chunk of HTML below the title and above the hero details.
78
78
79
79
80
- + makeExample('toh-2/ts/app/app.component.1.html' , 'heroes-template-1' , 'app.component.ts (heroes template)' )( format ='.' )
80
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'heroes-template-1' , 'app.component.ts (heroes template)' )( format ='.' )
81
81
82
82
:marked
83
83
Now you can fill the template with hero names.
@@ -89,7 +89,7 @@ code-example(language="sh" class="code-shell").
89
89
90
90
Modify the `<li>` tag by adding the built-in directive `*ngFor`.
91
91
92
- + makeExample('toh-2/ts/app/app.component.1.html' , 'heroes-ngfor-1' , 'app.component.ts (ngFor)' )
92
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'heroes-ngfor-1' , 'app.component.ts (ngFor)' )
93
93
94
94
95
95
.l-sub-section
@@ -116,7 +116,7 @@ code-example(language="sh" class="code-shell").
116
116
that uses the `hero` template variable to display the hero's properties.
117
117
118
118
119
- + makeExample('toh-2/ts/app/app.component.1.html' , 'ng-for' , 'app.component.ts (ngFor template)' )( format ="." )
119
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'ng-for' , 'app.component.ts (ngFor template)' )( format ="." )
120
120
121
121
:marked
122
122
When the browser refreshes, a list of heroes appears.
@@ -140,7 +140,7 @@ code-example(language="sh" class="code-shell").
140
140
The template for displaying heroes should look like this:
141
141
142
142
143
- + makeExample('toh-2/ts/app/app.component.1.html' , 'heroes-styled' , 'src/app/app.component.ts (styled heroes)' )( format ='.' )
143
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'heroes-styled' , 'src/app/app.component.ts (styled heroes)' )( format ='.' )
144
144
145
145
.l-main-section
146
146
:marked
@@ -158,7 +158,7 @@ code-example(language="sh" class="code-shell").
158
158
Add a click event binding to the `<li>` like this:
159
159
160
160
161
- + makeExample('toh-2/ts/app/app.component.1.html' , 'selectedHero-click' , 'app.component.ts (template excerpt)' )( format ='.' )
161
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'selectedHero-click' , 'app.component.ts (template excerpt)' )( format ='.' )
162
162
163
163
:marked
164
164
The parentheses identify the `<li>` element's `click` event as the target.
@@ -183,15 +183,15 @@ code-example(language="sh" class="code-shell").
183
183
The hero names should all be unselected before the user picks a hero, so
184
184
you won't initialize the `selectedHero` as you did with `hero`.
185
185
186
- Add an `onSelect` method that sets the `selectedHero` property to the `hero` that the user clicks.
186
+ Add an `onSelect() ` method that sets the `selectedHero` property to the `hero` that the user clicks.
187
187
+ makeExample('toh-2/ts/src/app/app.component.ts' , 'on-select' , 'src/app/app.component.ts (onSelect)' )( format ='.' )
188
188
189
189
:marked
190
190
The template still refers to the old `hero` property.
191
191
Bind to the new selectedHero property instead as follows:
192
192
193
193
194
- + makeExample('toh-2/ts/app/app.component.1.html' , 'selectedHero-details' , 'app.component.ts (template excerpt)' )( format ='.' )
194
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'selectedHero-details' , 'app.component.ts (template excerpt)' )( format ='.' )
195
195
196
196
:marked
197
197
### Hide the empty detail with ngIf
@@ -210,7 +210,7 @@ code-example(language="sh" class="code-shell").
210
210
Wrap the HTML hero detail content of the template with a `<div>`.
211
211
Then add the `ngIf` built-in directive and set it to the `selectedHero` property of the component.
212
212
213
- + makeExample('toh-2/ts/app/app.component.1.html' , 'ng-if' , 'src/app/app.component.ts (ngIf)' )( format ='.' )
213
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'ng-if' , 'src/app/app.component.ts (ngIf)' )( format ='.' )
214
214
215
215
.alert.is-critical
216
216
:marked
@@ -248,7 +248,7 @@ code-example(language="sh" class="code-shell").
248
248
img( src ='/resources/images/devguide/toh/heroes-list-selected.png' alt ="Selected hero" )
249
249
:marked
250
250
In the template, add the following `[class.selected]` binding to the `<li>`:
251
- + makeExample('toh-2/ts/app/app.component.1.html' , 'class-selected-1' , 'app.component.ts (setting the CSS class)' )( format ="." )
251
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'class-selected-1' , 'app.component.ts (setting the CSS class)' )( format ="." )
252
252
:marked
253
253
When the expression (`hero === selectedHero`) is `true`, Angular adds the `selected` CSS class.
254
254
When the expression is `false`, Angular removes the `selected` class.
@@ -260,7 +260,7 @@ code-example(language="sh" class="code-shell").
260
260
261
261
:marked
262
262
The final version of the `<li>` looks like this:
263
- + makeExample('toh-2/ts/app/app.component.1.html' , 'class-selected-2' , 'app.component.ts (styling each hero)' )( format ="." )
263
+ + makeExample('toh-2/ts/src/ app/app.component.1.html' , 'class-selected-2' , 'app.component.ts (styling each hero)' )( format ="." )
264
264
265
265
:marked
266
266
After clicking "Magneta", the list should look like this:
0 commit comments