| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | import { | 
					
						
							|  |  |  |   Component, | 
					
						
							|  |  |  |   EventEmitter, | 
					
						
							|  |  |  |   Input, | 
					
						
							|  |  |  |   Output, | 
					
						
							|  |  |  |   NgModule | 
					
						
							|  |  |  | } from '@angular/core'; | 
					
						
							|  |  |  | import { BrowserModule } from '@angular/platform-browser'; | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'my-confirm', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <button (click)="onOkClick()"> | 
					
						
							|  |  |  |       {{okMsg}} | 
					
						
							|  |  |  |     </button> | 
					
						
							|  |  |  |     <button (click)="onNotOkClick()"> | 
					
						
							|  |  |  |       {{notOkMsg}} | 
					
						
							|  |  |  |     </button> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | class ConfirmComponent { | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   @Input() okMsg: string; | 
					
						
							|  |  |  |   @Input('cancelMsg') notOkMsg: string; | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |   @Output() ok = | 
					
						
							|  |  |  |     new EventEmitter(); | 
					
						
							|  |  |  |   @Output('cancel') notOk = | 
					
						
							|  |  |  |     new EventEmitter(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   onOkClick() { | 
					
						
							|  |  |  |     this.ok.next(true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   onNotOkClick() { | 
					
						
							|  |  |  |     this.notOk.next(true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'hero-io', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <my-confirm [okMsg]="'OK'" | 
					
						
							|  |  |  |                 [cancelMsg]="'Cancel'" | 
					
						
							|  |  |  |                 (ok)="onOk()" | 
					
						
							|  |  |  |                 (cancel)="onCancel()"> | 
					
						
							|  |  |  |     </my-confirm> | 
					
						
							|  |  |  |     <span *ngIf="okClicked">OK clicked</span> | 
					
						
							|  |  |  |     <span *ngIf="cancelClicked">Cancel clicked</span> | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   `
 | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | class AppComponent { | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   okClicked: boolean; | 
					
						
							|  |  |  |   cancelClicked: boolean; | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   onOk() { | 
					
						
							|  |  |  |     this.okClicked = true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   onCancel() { | 
					
						
							|  |  |  |     this.cancelClicked = true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @NgModule({ | 
					
						
							|  |  |  |   imports: [ BrowserModule ], | 
					
						
							|  |  |  |   declarations: [ | 
					
						
							|  |  |  |     AppComponent, | 
					
						
							|  |  |  |     ConfirmComponent | 
					
						
							|  |  |  |   ], | 
					
						
							|  |  |  |   bootstrap: [ AppComponent ] | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class HeroesIOModule { } |