| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-03-25 16:03:53 -07:00
										 |  |  | import 'package:angular2/core.dart'; | 
					
						
							| 
									
										
										
										
											2016-01-27 15:51:50 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | import 'logger_service.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 |  |  | int _nextId = 1; | 
					
						
							| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 |  |  | // #docregion spy-directive
 | 
					
						
							| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | // Spy on any element to which it is applied.
 | 
					
						
							|  |  |  | // Usage: <div mySpy>...</div>
 | 
					
						
							|  |  |  | @Directive(selector: '[mySpy]') | 
					
						
							| 
									
										
										
										
											2016-06-28 13:13:58 -07:00
										 |  |  | class SpyDirective implements OnInit, OnDestroy { | 
					
						
							| 
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 |  |  |   final LoggerService _logger; | 
					
						
							| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-28 13:13:58 -07:00
										 |  |  |   SpyDirective(this._logger); | 
					
						
							| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   ngOnInit() => _logIt('onInit'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ngOnDestroy() => _logIt('onDestroy'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 |  |  |   _logIt(String msg) => _logger.log('Spy #${_nextId++} $msg'); | 
					
						
							| 
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 |  |  | // #enddocregion spy-directive
 |