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';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'spy_directive.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								@Component(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    selector: 'spy-parent',
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    templateUrl: 'spy_component.html',
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    styles: const [
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      '.parent {background: khaki}',
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      '.heroes {background: LightYellow; padding: 0 8px}'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    ],
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-28 13:13:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    directives: const [SpyDirective],
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    providers: const [LoggerService])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class SpyParentComponent {
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  final LoggerService _logger;
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  String newName = 'Herbie';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  List<String> heroes = ['Windstorm', 'Magneta'];
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  SpyParentComponent(this._logger);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  List<String> get logs => _logger.logs;
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  addHero() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    if (newName.trim().isNotEmpty) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      heroes.add(newName.trim());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      newName = '';
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      _logger.tick();
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  // removeHero(String hero) { } is not used.
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-28 13:13:58 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  void reset() {
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    _logger.log('-- reset --');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    heroes.clear();
							 | 
						
					
						
							
								
									
										
										
										
											2016-05-06 06:17:34 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    _logger.tick();
							 | 
						
					
						
							
								
									
										
										
										
											2016-01-20 19:14:46 -02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  }
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |