Skip to content

Instantly share code, notes, and snippets.

@LayZeeDK
Last active September 16, 2019 04:58
Show Gist options
  • Save LayZeeDK/0671081a29a94085f3fcbcd07771bcc5 to your computer and use it in GitHub Desktop.
Save LayZeeDK/0671081a29a94085f3fcbcd07771bcc5 to your computer and use it in GitHub Desktop.
Dashboard: Mixed component model
import { Component, OnInit } from '@angular/core';
import { Hero } from '../hero';
import { HeroService } from '../hero.service';
@Component({
selector: 'app-dashboard',
styleUrls: ['./dashboard.component.css'],
templateUrl: './dashboard.component.html',
})
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));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment