| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | // #docplaster
 | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  | // #docregion , v2
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | import { Component, OnInit } from '@angular/core'; | 
					
						
							|  |  |  | import { ActivatedRoute, Params } from '@angular/router'; | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | import { Hero } from './hero'; | 
					
						
							|  |  |  | import { HeroService } from './hero.service'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'my-hero-detail', | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  |   // #docregion templateUrl
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  |   templateUrl: 'app/hero-detail.component.html', | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  |   // #enddocregion templateUrl, v2
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:31:27 +01:00
										 |  |  |   styleUrls: ['app/hero-detail.component.css'] | 
					
						
							| 
									
										
										
										
											2016-06-10 09:37:33 -07:00
										 |  |  |   // #docregion v2
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | }) | 
					
						
							|  |  |  | // #docregion implement
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | export class HeroDetailComponent implements OnInit { | 
					
						
							| 
									
										
										
										
											2016-06-10 09:37:33 -07:00
										 |  |  |   // #enddocregion implement
 | 
					
						
							| 
									
										
										
										
											2016-04-20 16:03:11 +02:00
										 |  |  |   hero: Hero; | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-10 09:37:33 -07:00
										 |  |  |   // #docregion ctor
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  |   constructor( | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     private heroService: HeroService, | 
					
						
							| 
									
										
										
										
											2016-06-19 00:20:38 -04:00
										 |  |  |     private route: ActivatedRoute) { | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-10 09:37:33 -07:00
										 |  |  |   // #enddocregion ctor
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  |   // #docregion ngOnInit
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  |   ngOnInit() { | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |     this.route.params.forEach((params: Params) => { | 
					
						
							| 
									
										
										
										
											2016-06-19 00:20:38 -04:00
										 |  |  |       let id = +params['id']; | 
					
						
							|  |  |  |       this.heroService.getHero(id) | 
					
						
							|  |  |  |         .then(hero => this.hero = hero); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  |   // #enddocregion ngOnInit
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  |   // #docregion goBack
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  |   goBack() { | 
					
						
							|  |  |  |     window.history.back(); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-08-17 13:31:40 -07:00
										 |  |  | // #enddocregion goBack
 | 
					
						
							| 
									
										
										
										
											2015-12-23 09:42:57 -08:00
										 |  |  | } |