docs: fix ch 4 so it compiles in strict mode (#40970)

Fixes error: `TS2564: Property 'heroes' has no initializer and is not definitely assigned in the constructor`
and makes `hero` property consistent with ch 3 (ref: #40942)

PR Close #40970
This commit is contained in:
Carl Fredrik Samson 2021-02-23 20:27:02 +01:00 committed by Andrew Scott
parent 011a527497
commit 03de2f2b78

View File

@ -15,10 +15,10 @@ import { MessageService } from '../message.service';
}) })
export class HeroesComponent implements OnInit { export class HeroesComponent implements OnInit {
selectedHero: Hero; selectedHero?: Hero;
// #docregion heroes // #docregion heroes
heroes: Hero[]; heroes: Hero[] = [];
// #enddocregion heroes // #enddocregion heroes
constructor(private heroService: HeroService, private messageService: MessageService) { } constructor(private heroService: HeroService, private messageService: MessageService) { }