| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  | /* tslint:disable use-input-property-decorator use-output-property-decorator */ | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  | // #docplaster
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Component, EventEmitter, Input, Output } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Hero } from './hero'; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion input-output-2
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  | // #enddocregion input-output-2
 | 
					
						
							|  |  |  |   selector: 'hero-detail', | 
					
						
							|  |  |  |   // #docregion input-output-2
 | 
					
						
							|  |  |  |   inputs: ['hero'], | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |   outputs: ['deleteRequest'], | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   // #enddocregion input-output-2
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   styles: ['button { margin-left: 8px} div {margin: 8px 0} img {height:24px}'], | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |   // #docregion template-1
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   template: `
 | 
					
						
							| 
									
										
										
										
											2016-01-27 18:54:33 -08:00
										 |  |  |   <div> | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |     <img src="{{heroImageUrl}}"> | 
					
						
							|  |  |  |     <span [style.text-decoration]="lineThrough"> | 
					
						
							|  |  |  |       {{prefix}} {{hero?.fullName}} | 
					
						
							|  |  |  |     </span> | 
					
						
							|  |  |  |     <button (click)="delete()">Delete</button> | 
					
						
							|  |  |  |   </div>`
 | 
					
						
							|  |  |  |   // #enddocregion template-1
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | // #docregion input-output-2
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | // #enddocregion input-output-2
 | 
					
						
							|  |  |  | export class HeroDetailComponent { | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   hero: Hero = new Hero('', 'Zzzzzzzz'); // default sleeping hero
 | 
					
						
							|  |  |  |   // heroImageUrl = 'http://www.wpclipart.com/cartoon/people/hero/hero_silhoutte_T.png';
 | 
					
						
							|  |  |  |   // Public Domain terms of use: http://www.wpclipart.com/terms.html
 | 
					
						
							|  |  |  |   heroImageUrl = 'images/hero.png'; | 
					
						
							|  |  |  |   lineThrough = ''; | 
					
						
							|  |  |  |   @Input() prefix = ''; | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion deleteRequest
 | 
					
						
							|  |  |  |   // This component make a request but it can't actually delete a hero.
 | 
					
						
							|  |  |  |   deleteRequest = new EventEmitter<Hero>(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   delete() { | 
					
						
							|  |  |  |     this.deleteRequest.emit(this.hero); | 
					
						
							|  |  |  |     // #enddocregion deleteRequest
 | 
					
						
							|  |  |  |     this.lineThrough = this.lineThrough ? '' : 'line-through'; | 
					
						
							|  |  |  |     // #docregion deleteRequest
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  | // #enddocregion deleteRequest
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'big-hero-detail', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |   <div style="border: 1px solid black; padding:3px"> | 
					
						
							|  |  |  |     <img src="{{heroImageUrl}}" style="float:left; margin-right:8px;"> | 
					
						
							|  |  |  |     <div><b>{{hero?.fullName}}</b></div> | 
					
						
							|  |  |  |     <div>First: {{hero?.firstName}}</div> | 
					
						
							|  |  |  |     <div>Last: {{hero?.lastName}}</div> | 
					
						
							|  |  |  |     <div>Birthdate: {{hero?.birthdate | date:'longDate'}}</div> | 
					
						
							|  |  |  |     <div>Web: <a href="{{hero?.url}}" target="_blank">{{hero?.url}}</a></div> | 
					
						
							|  |  |  |     <div>Rate/hr: {{hero?.rate | currency:'EUR'}}</div> | 
					
						
							|  |  |  |     <br clear="all"> | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |     <button (click)="delete()">Delete</button> | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   </div> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class BigHeroDetailComponent extends HeroDetailComponent { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion input-output-1
 | 
					
						
							|  |  |  |   @Input()  hero: Hero; | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |   @Output() deleteRequest = new EventEmitter<Hero>(); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   // #enddocregion input-output-1
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-17 10:59:14 -08:00
										 |  |  |   delete() { | 
					
						
							|  |  |  |     this.deleteRequest.emit(this.hero); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | } |