angular-tour-of-heroes/src/app/dashboard/dashboard.component.ts
2022-09-30 09:30:47 +02:00

24 lines
555 B
TypeScript

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.scss']
})
export class DashboardComponent implements OnInit {
heroes: Hero[] = []
constructor(private heroService: HeroService) { }
ngOnInit(): void {
this.getHeroes()
}
getHeroes(): void {
this.heroService.getHeroes().subscribe(heroes => this.heroes = heroes.slice(1,5))
}
}