angular-docs-cn/public/docs/_examples/toh-5/ts/app/dashboard.component.ts
Ward Bell fa99a8b0b2 docs(toh-5): dashboard uses [routerLink] bindings #998 (#2718)
* docs(toh-5): dashboard uses [routerLink] bindings #998
closes #998

* chore: temp add toh-5 to bad-code-excerpt-skip-patterns.txt
2016-11-03 10:25:01 -07:00

37 lines
839 B
TypeScript

// #docplaster
// #docregion
// #docregion imports
import { Component, OnInit } from '@angular/core';
import { Hero } from './hero';
import { HeroService } from './hero.service';
// #enddocregion imports
// #docregion metadata
@Component({
moduleId: module.id,
selector: 'my-dashboard',
templateUrl: 'dashboard.component.html',
// #enddocregion metadata
// #docregion css
styleUrls: [ 'dashboard.component.css' ]
// #enddocregion css
// #docregion metadata
})
// #enddocregion metadata
// #docregion class
export class DashboardComponent implements OnInit {
heroes: Hero[] = [];
// #docregion ctor
constructor(private heroService: HeroService) { }
// #enddocregion ctor
ngOnInit(): void {
this.heroService.getHeroes()
.then(heroes => this.heroes = heroes.slice(1, 5));
}
}
// #enddocregion class