-
Notifications
You must be signed in to change notification settings - Fork 0
/
hero.component.ts
35 lines (29 loc) · 1 KB
/
hero.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
import { Component, OnInit } from '@angular/core';
import { Hero } from './hero';
import { HeroesDeliveryService } from './all-heroes.service'
//import { HEROES } from './all.heroes';
@Component({
selector: ".hero-component",
templateUrl: "./templates/hero.component.html",
styleUrls: ["./styles/hero.component.css"]
})
export class HeroComponent implements OnInit{
hero: Hero;
HEROES:Hero[];
title:string = 'Heroes Catalog - All Stars!';
constructor(private heroesDeliveryService:HeroesDeliveryService){
// this.hero = {"id":"hro1","name":"Silverhand","type":"Warrior","weapon":"Sword","level":8,"avatar":"./images/Silverhand.jpg"}
//this.hero = Heroes[1];
//this.getHeroesInfo();
}
getHeroesInfo():void{
console.log('before get heroes info');
this.heroesDeliveryService.getHeroesInfo()
.then((heroes)=> this.HEROES = heroes)
.catch((error)=>console.log(`Connection timeout? Check service! ${error}`));
console.log('after getting heroes info');
}
ngOnInit():void{
this.getHeroesInfo();
}
}