24 lines
657 B
TypeScript
24 lines
657 B
TypeScript
import {Component, OnInit} from 'angular2/core';
|
|
import {Router} from 'angular2/router';
|
|
import {Hero} from './hero';
|
|
import {HeroService} from './hero.service';
|
|
|
|
@Component({
|
|
selector: 'my-dashboard',
|
|
templateUrl: 'app/dashboard.component.html',
|
|
styleUrls: ['app/dashboard.component.css']
|
|
})
|
|
export class DashboardComponent implements OnInit {
|
|
public heroes: Hero[] = [];
|
|
|
|
constructor(private _heroService: HeroService, private _router: Router) { }
|
|
|
|
ngOnInit() {
|
|
this._heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1,5));
|
|
}
|
|
|
|
gotoDetail(hero: Hero) {
|
|
this._router.navigate(['HeroDetail', { id: hero.id }]);
|
|
}
|
|
}
|