parent
9ed12f465f
commit
9784c2fa16
|
@ -1,7 +1,7 @@
|
||||||
// #docregion example
|
// #docregion example
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { Hero, HeroService } from '../shared/index';
|
import { Hero, HeroService } from '../shared';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'toh-hero-list',
|
selector: 'toh-hero-list',
|
||||||
|
@ -10,13 +10,13 @@ import { Hero, HeroService } from '../shared/index';
|
||||||
export class HeroListComponent implements OnInit {
|
export class HeroListComponent implements OnInit {
|
||||||
heroes: Hero[];
|
heroes: Hero[];
|
||||||
constructor(private heroService: HeroService) {}
|
constructor(private heroService: HeroService) {}
|
||||||
getHeros() {
|
getHeroes() {
|
||||||
this.heroes = [];
|
this.heroes = [];
|
||||||
this.heroService.getHeroes()
|
this.heroService.getHeroes()
|
||||||
.subscribe(heroes => this.heroes = heroes);
|
.subscribe(heroes => this.heroes = heroes);
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getHeros();
|
this.getHeroes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// #enddocregion example
|
// #enddocregion example
|
||||||
|
|
Loading…
Reference in New Issue