Skip to content

Commit

Permalink
Handle undefined selectedHero
Browse files Browse the repository at this point in the history
  • Loading branch information
faulhaberben committed Jun 19, 2023
1 parent ac13b65 commit 2c3bb15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ <h2>My Heroes</h2>
</ul>

<!-- #docregion hero-detail-binding -->
<app-hero-detail [hero]="selectedHero"></app-hero-detail>
<ng-container *ngIf="selectedHero">
<app-hero-detail [hero]="selectedHero"></app-hero-detail>
<ng-container>
<!-- #enddocregion hero-detail-binding -->
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class HeroesComponent {

heroes = HEROES;

selectedHero!: Hero;
selectedHero?: Hero;

onSelect(hero: Hero): void {
this.selectedHero = hero;
Expand Down

0 comments on commit 2c3bb15

Please sign in to comment.