Jesús Rodríguez e9a41bac47 docs(toh): add return types
closes #1983
2016-08-17 22:41:06 -07:00

45 lines
992 B
TypeScript

// #docplaster
// #docregion
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Hero } from './hero';
import { HeroService } from './hero.service';
// #docregion renaming, metadata
@Component({
selector: 'my-heroes',
// #enddocregion renaming
templateUrl: 'app/heroes.component.html',
styleUrls: ['app/heroes.component.css']
// #docregion renaming
})
// #enddocregion metadata
// #docregion class
export class HeroesComponent implements OnInit {
// #enddocregion renaming
heroes: Hero[];
selectedHero: Hero;
constructor(
private router: Router,
private heroService: HeroService) { }
getHeroes(): void {
this.heroService.getHeroes().then(heroes => this.heroes = heroes);
}
ngOnInit(): void {
this.getHeroes();
}
onSelect(hero: Hero): void {
this.selectedHero = hero;
}
gotoDetail(): void {
this.router.navigate(['/detail', this.selectedHero.id]);
}
// #docregion renaming
}