| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | import { Directive, ElementRef, Input } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Directive({ | 
					
						
							| 
									
										
										
										
											2015-12-10 20:27:41 -08:00
										 |  |  |   selector: '[myHighlight]', | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   // #docregion host
 | 
					
						
							|  |  |  |   host: { | 
					
						
							|  |  |  |     '(mouseenter)': 'onMouseEnter()', | 
					
						
							|  |  |  |     '(mouseleave)': 'onMouseLeave()' | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion host
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-16 19:38:07 -08:00
										 |  |  | export class HighlightDirective { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   // #docregion ctor
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   private el:HTMLElement; | 
					
						
							|  |  |  |   constructor(el: ElementRef) { this.el = el.nativeElement; } | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   // #enddocregion ctor
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion mouse-methods
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   onMouseEnter() { this.highlight("yellow"); } | 
					
						
							|  |  |  |   onMouseLeave() { this.highlight(null); } | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   private highlight(color: string) { | 
					
						
							|  |  |  |     this.el.style.backgroundColor = color; | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion mouse-methods
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | // #enddocregion
 |