X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fapp%2Fdashboard%2Fdashboard.component.ts;fp=src%2Fapp%2Fdashboard%2Fdashboard.component.ts;h=c559ccdd4d18e4eb94bc46ebbba74deb96cea22d;hb=2f6f2d86ff7765914cd9105069181ed1f1792f44;hp=0000000000000000000000000000000000000000;hpb=0666181cc32377d48501a42c465b08d3e660ab62;p=examples%2Fangular-tour-of-heroes diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts new file mode 100644 index 0000000..c559ccd --- /dev/null +++ b/src/app/dashboard/dashboard.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { Hero } from '../hero'; +import { HeroService } from '../hero.service'; + +@Component({ + selector: 'app-dashboard', + templateUrl: './dashboard.component.html', + styleUrls: [ './dashboard.component.css' ] +}) +export class DashboardComponent implements OnInit { + heroes: Hero[] = []; + + constructor(private heroService: HeroService) { } + + ngOnInit() { + this.getHeroes(); + } + + getHeroes(): void { + this.heroService.getHeroes() + .subscribe(heroes => this.heroes = heroes.slice(1, 5)); + } +}