I work on code snippet described on https://angular.io/tutorial/toh-pt5
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
constructor(private heroService: HeroService) { }
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
}
}
And my question about this code part:
.then(heroes => this.heroes = heroes.slice(1, 5));
is it possible to create a method in DashboardComponent and pass it as argument instead of function? Is the functional approach here anything better than a method inside DashboardComponent class?