angular-docs-cn/public/docs/_examples/toh-5/ts/app/dashboard.component.2.ts

28 lines
617 B
TypeScript
Raw Normal View History

2015-12-23 12:42:57 -05:00
// #docplaster
// #docregion imports
2016-04-27 14:28:22 -04:00
import { Component, OnInit } from '@angular/core';
2015-12-23 12:42:57 -05:00
import { Hero } from './hero';
import { HeroService } from './hero.service';
// #enddocregion imports
@Component({
selector: 'my-dashboard',
templateUrl: 'app/dashboard.component.html'
})
// #docregion component
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
constructor(private heroService: HeroService) { }
2015-12-23 12:42:57 -05:00
ngOnInit() {
this.heroService.getHeroes()
2015-12-23 12:42:57 -05:00
.then(heroes => this.heroes = heroes.slice(1,5));
}
gotoDetail(){ /* not implemented yet */}
}
// #enddocregion component