| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  | /* tslint:disable use-output-property-decorator */ | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  | // #docplaster
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Directive, ElementRef, EventEmitter, Output } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  | @Directive({selector: '[myClick]'}) | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | export class MyClickDirective { | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  |   // #docregion my-click-output-1
 | 
					
						
							| 
									
										
										
										
											2016-01-18 23:54:27 -08:00
										 |  |  |   @Output('myClick') clicks = new EventEmitter<string>(); //  @Output(alias) propertyName = ...
 | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  |  // #enddocregion my-click-output-1
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   toggle = false; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   constructor(el: ElementRef) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     el.nativeElement | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |       .addEventListener('click', (event: Event) => { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |         this.toggle = !this.toggle; | 
					
						
							|  |  |  |         this.clicks.emit(this.toggle ? 'Click!' : ''); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |       }); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  | // #docregion my-click-output-2
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | @Directive({ | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  | // #enddocregion my-click-output-2
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   selector: '[myClick2]', | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  | // #docregion my-click-output-2
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   outputs: ['clicks:myClick']  // propertyName:alias
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2015-12-13 22:29:37 -08:00
										 |  |  | // #enddocregion my-click-output-2
 | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  | export class MyClickDirective2 { | 
					
						
							|  |  |  |   clicks = new EventEmitter<string>(); | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   toggle = false; | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   constructor(el: ElementRef) { | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |     el.nativeElement | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |       .addEventListener('click', (event: Event) => { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |         this.toggle = !this.toggle; | 
					
						
							|  |  |  |         this.clicks.emit(this.toggle ? 'Click2!' : ''); | 
					
						
							| 
									
										
										
										
											2015-12-07 13:31:26 -08:00
										 |  |  |       }); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | } |