X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fheroes%2Fheroes.component.ts;fp=src%2Fapp%2Fheroes%2Fheroes.component.ts;h=94f426656a78890c89a2966a9d9d7687511858eb;hb=ef15a90ba71bcff7765f089af11e2ad22752a352;hp=a09ff133d75211d6bf805b2e5f0d49eef48f3581;hpb=892eb73ff8719be6783a042d78af0a2a19e857b6;p=examples%2Fangular-tour-of-heroes diff --git a/src/app/heroes/heroes.component.ts b/src/app/heroes/heroes.component.ts index a09ff13..94f4266 100644 --- a/src/app/heroes/heroes.component.ts +++ b/src/app/heroes/heroes.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { Hero } from '../hero'; -import { HEROES } from '../mock-heroes'; +import { HeroService } from '../hero.service'; @Component({ selector: 'app-heroes', @@ -9,7 +9,7 @@ import { HEROES } from '../mock-heroes'; }) export class HeroesComponent implements OnInit { - heroes = HEROES; + heroes: Hero[]; selectedHero : Hero; @@ -17,9 +17,13 @@ export class HeroesComponent implements OnInit { this.selectedHero = hero; } - constructor() { } + constructor(private heroService : HeroService) { } ngOnInit() { + this.getHeroes(); } + getHeroes() : void { + this.heroes = this.heroService.getHeroes(); + } }