2016-05-03 14:06:32 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { Router } from '@angular/router-deprecated';
|
|
|
|
|
|
|
|
|
|
import { Hero } from './hero';
|
|
|
|
|
import { HeroService } from './hero.service';
|
2015-11-15 18:04:43 -08:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'my-dashboard',
|
|
|
|
|
templateUrl: 'app/dashboard.component.html',
|
|
|
|
|
styleUrls: ['app/dashboard.component.css']
|
|
|
|
|
})
|
|
|
|
|
export class DashboardComponent implements OnInit {
|
2016-03-24 13:31:27 +01:00
|
|
|
heroes: Hero[] = [];
|
2015-11-15 18:04:43 -08:00
|
|
|
|
2016-05-03 14:06:32 +02:00
|
|
|
constructor(private heroService: HeroService, private _router: Router) { }
|
2015-11-15 18:04:43 -08:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2016-05-03 14:06:32 +02:00
|
|
|
this.heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5));
|
2015-11-15 18:04:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gotoDetail(hero: Hero) {
|
2015-12-23 09:42:57 -08:00
|
|
|
let link = ['HeroDetail', { id: hero.id }];
|
|
|
|
|
this._router.navigate(link);
|
2015-11-15 18:04:43 -08:00
|
|
|
}
|
|
|
|
|
}
|