23 lines
553 B
TypeScript
Raw Normal View History

2016-03-26 12:18:13 -04:00
// #docregion
2016-04-27 11:28:22 -07:00
import {Injectable} from '@angular/core';
2016-03-26 12:18:13 -04:00
import {Hero} from './hero';
@Injectable()
export class HeroService {
//TODO move to database
2016-05-01 23:04:47 +02:00
private _heroes:Array<Hero> = [
2016-03-26 12:18:13 -04:00
new Hero(1, 'RubberMan','Hero of many talents', '123-456-7899'),
new Hero(2, 'Magma','Hero of all trades', '555-555-5555'),
new Hero(3, 'Mr. Nice','The name says it all','111-222-3333')
];
getHeroById(id:number):Hero{
2016-05-01 23:04:47 +02:00
return this._heroes.filter(hero => hero.id === id)[0];
2016-03-26 12:18:13 -04:00
}
getAllHeroes():Array<Hero>{
2016-05-01 23:04:47 +02:00
return this._heroes;
2016-03-26 12:18:13 -04:00
}
2016-05-01 23:04:47 +02:00
}