diff --git a/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.ts b/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.ts
index bee5856586..f367a9baa0 100644
--- a/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.ts
+++ b/aio/content/examples/toh-pt2/src/app/heroes/heroes.component.ts
@@ -12,16 +12,17 @@ import { HEROES } from '../mock-heroes';
styleUrls: ['./heroes.component.css']
})
// #enddocregion metadata
+
+// #docregion component
export class HeroesComponent implements OnInit {
// #docregion heroes
heroes = HEROES;
// #enddocregion heroes
-
+ // #enddocregion component
// #docregion on-select
selectedHero: Hero;
-
- // #enddocregion on-select
+ // #enddocregion on-select
constructor() { }
diff --git a/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.html b/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.html
index 946a4d5fdb..ea2387fdc1 100644
--- a/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.html
+++ b/aio/content/examples/toh-pt5/src/app/dashboard/dashboard.component.html
@@ -3,9 +3,9 @@
-
{{hero.name}}
+
diff --git a/aio/content/examples/toh-pt6/src/app/in-memory-data.service.ts b/aio/content/examples/toh-pt6/src/app/in-memory-data.service.ts
index 005545c19a..9679f21055 100644
--- a/aio/content/examples/toh-pt6/src/app/in-memory-data.service.ts
+++ b/aio/content/examples/toh-pt6/src/app/in-memory-data.service.ts
@@ -1,5 +1,6 @@
// #docregion , init
import { InMemoryDbService } from 'angular-in-memory-web-api';
+import { Hero } from './hero';
export class InMemoryDataService implements InMemoryDbService {
createDb() {
@@ -17,4 +18,13 @@ export class InMemoryDataService implements InMemoryDbService {
];
return {heroes};
}
+
+ // Overrides the genId method to ensure that a hero always has an id.
+ // If the heroes array is empty,
+ // the method below returns the initial number (11).
+ // if the heroes array is not empty, the method below returns the highest
+ // hero id + 1.
+ genId(heroes: Hero[]): number {
+ return heroes.length > 0 ? Math.max(...heroes.map(hero => hero.id)) + 1 : 11;
+ }
}
diff --git a/aio/content/tutorial/toh-pt2.md b/aio/content/tutorial/toh-pt2.md
index 48e3a0d154..4a2d7e657f 100644
--- a/aio/content/tutorial/toh-pt2.md
+++ b/aio/content/tutorial/toh-pt2.md
@@ -28,9 +28,9 @@ Open the `HeroesComponent` class file and import the mock `HEROES`.
-Add a `heroes` property to the class that exposes these heroes for binding.
+In the same file (`HeroesComponent` class), define a component property called `heroes` to expose `HEROES` array for binding.
-
+
### List heroes with _*ngFor_
@@ -245,6 +245,7 @@ Here are the code files discussed on this page, including the `HeroesComponent`
+
## Summary
diff --git a/aio/content/tutorial/toh-pt3.md b/aio/content/tutorial/toh-pt3.md
index ff53e9a032..6f32e7460e 100644
--- a/aio/content/tutorial/toh-pt3.md
+++ b/aio/content/tutorial/toh-pt3.md
@@ -1,6 +1,6 @@
# Master/Detail Components
-At the moment, the `HeroesComponent` displays both the list of heroes and the selected hero's details.
+At the moment, the `HeroesComponent` displays both the list of heroes and the selected hero's details.
Keeping all features in one component as the application grows will not be maintainable.
You'll want to split up large components into smaller sub-components, each focused on a specific task or workflow.
@@ -18,7 +18,19 @@ Use the Angular CLI to generate a new component named `hero-detail`.
ng generate component hero-detail
-The command scaffolds the `HeroDetailComponent` files and declares the component in `AppModule`.
+The command scaffolds the following:
+
+* Creates a directory `src/app/hero-detail`.
+
+Inside that directory four files are generated:
+
+* A CSS file for the component styles.
+* An HTML file for the component template.
+* A TypeScript file with a component class named `HeroDetailComponent`.
+* A test file for the `HeroDetailComponent` class.
+
+The command also adds the `HeroDetailComponent` as a declaration in the `@NgModule` decorator of the `src/app/app.module.ts` file.
+
### Write the template
@@ -26,7 +38,7 @@ Cut the HTML for the hero detail from the bottom of the `HeroesComponent` templa
The pasted HTML refers to a `selectedHero`.
The new `HeroDetailComponent` can present _any_ hero, not just a selected hero.
-So replace "selectedHero" with "hero" everywhere in the template.
+So replace "selectedHero" with "hero" everywhere in the template.
When you're done, the `HeroDetailComponent` template should look like this:
@@ -41,11 +53,11 @@ which is of type `Hero`.
Open the `HeroDetailComponent` class file and import the `Hero` symbol.
-
-The `hero` property
+The `hero` property
[must be an _Input_ property](guide/template-syntax#inputs-outputs "Input and Output properties"),
annotated with the `@Input()` decorator,
because the _external_ `HeroesComponent` [will bind to it](#heroes-component-template) like this.
@@ -64,17 +76,17 @@ Add a `hero` property, preceded by the `@Input()` decorator.
That's the only change you should make to the `HeroDetailComponent` class.
-There are no more properties. There's no presentation logic.
+There are no more properties. There's no presentation logic.
This component simply receives a hero object through its `hero` property and displays it.
## Show the `HeroDetailComponent`
-The `HeroesComponent` is still a master/detail view.
+The `HeroesComponent` is still a master/detail view.
It used to display the hero details on its own, before you cut that portion of the template. Now it will delegate to the `HeroDetailComponent`.
The two components will have a parent/child relationship.
-The parent `HeroesComponent` will control the child `HeroDetailComponent`
+The parent `HeroesComponent` will control the child `HeroDetailComponent`
by sending it a new hero to display whenever
the user selects a hero from the list.
@@ -155,6 +167,6 @@ Here are the code files discussed on this page and your app should look like thi
* You used a [property binding](guide/template-syntax#property-binding) to give the parent `HeroesComponent` control over the child `HeroDetailComponent`.
-* You used the [`@Input` decorator](guide/template-syntax#inputs-outputs)
+* You used the [`@Input` decorator](guide/template-syntax#inputs-outputs)
to make the `hero` property available for binding
by the external `HeroesComponent`.
diff --git a/aio/content/tutorial/toh-pt6.md b/aio/content/tutorial/toh-pt6.md
index a5f0955f3d..2219f50795 100644
--- a/aio/content/tutorial/toh-pt6.md
+++ b/aio/content/tutorial/toh-pt6.md
@@ -66,7 +66,7 @@ which you will create in a moment.
Add the `HttpClientInMemoryWebApiModule` to the `@NgModule.imports` array—
-_after importing the `HttpClient`_,
+_after importing the `HttpClientModule`_,
—while configuring it with the `InMemoryDataService`.
-Define the `heroesUrl` with the address of the heroes resource on the server.
+Define the `heroesUrl` of the form `:base/:collectionName` with the address of the heroes resource on the server.
+ Here `base` is the resource to which requests are made,
+ and `collectionName` is the heroes data object in the `in-memory-data-service.ts`.
@@ -629,6 +634,16 @@ Here are the code files discussed on this page (all in the `src/app/` folder).
+{@a dashboardcomponent}
+#### _DashboardComponent_
+
+
+
+
+
+
{@a herosearchcomponent}
#### _HeroSearchComponent_