forked from angular/angular.io
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdashboard.component.ts
44 lines (38 loc) · 1.01 KB
/
dashboard.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// #docplaster
// #docregion
import { Component, OnInit } from 'angular2/core';
// #docregion import-router
import { Router } from 'angular2/router';
// #enddocregion import-router
import { Hero } from './hero';
import { HeroService } from './hero.service';
@Component({
selector: 'my-dashboard',
// #docregion template-url
templateUrl: 'app/dashboard.component.html',
// #enddocregion template-url
// #docregion css
styleUrls: ['app/dashboard.component.css']
// #enddocregion css
})
// #docregion component
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
// #docregion ctor
constructor(
private _router: Router,
private _heroService: HeroService) {
}
// #enddocregion ctor
ngOnInit() {
this._heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1,5));
}
// #docregion goto-detail
gotoDetail(hero: Hero) {
let link = ['HeroDetail', { id: hero.id }];
this._router.navigate(link);
}
// #enddocregion goto-detail
}
// #enddocregion