| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | (function(app) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var ActiveLabelComponent = ng.core.Component({ | 
					
						
							|  |  |  |     selector: 'active-label', | 
					
						
							|  |  |  |     template: '<span class="active-label"' + | 
					
						
							|  |  |  |                     '*ngIf="active">' + | 
					
						
							|  |  |  |       'Active' + | 
					
						
							|  |  |  |     '</span>' | 
					
						
							|  |  |  |   }).Class({ | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |     constructor: [function() { }], | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |     activate: function() { | 
					
						
							|  |  |  |       this.active = true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-04-27 11:28:22 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |   // #docregion content
 | 
					
						
							|  |  |  |   var HeroComponent = ng.core.Component({ | 
					
						
							| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  |     selector: 'a-hero', | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |     template: '<h2 [class.active]=active>' + | 
					
						
							|  |  |  |       '{{hero.name}} ' + | 
					
						
							|  |  |  |       '<ng-content></ng-content>' + | 
					
						
							|  |  |  |     '</h2>', | 
					
						
							|  |  |  |     inputs: ['hero'], | 
					
						
							|  |  |  |     queries: { | 
					
						
							|  |  |  |       label: new ng.core.ContentChild( | 
					
						
							|  |  |  |                    ActiveLabelComponent) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }).Class({ | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |     constructor: [function() { }], | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |     activate: function() { | 
					
						
							|  |  |  |       this.active = true; | 
					
						
							|  |  |  |       this.label.activate(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   app.HeroQueriesComponent = HeroComponent; | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |   // #enddocregion content
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // #docregion view
 | 
					
						
							|  |  |  |   var AppComponent = ng.core.Component({ | 
					
						
							|  |  |  |     selector: 'heroes-queries', | 
					
						
							|  |  |  |     template: | 
					
						
							| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  |       '<a-hero *ngFor="let hero of heroData"' + | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |             '[hero]="hero">' + | 
					
						
							|  |  |  |         '<active-label></active-label>' + | 
					
						
							| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  |       '</a-hero>' + | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |       '<button (click)="activate()">' + | 
					
						
							|  |  |  |         'Activate' + | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |       '</button>',     | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |     queries: { | 
					
						
							|  |  |  |       heroCmps: new ng.core.ViewChildren( | 
					
						
							|  |  |  |                       HeroComponent) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }).Class({ | 
					
						
							|  |  |  |     constructor: function() { | 
					
						
							|  |  |  |       this.heroData = [ | 
					
						
							|  |  |  |         {id: 1, name: 'Windstorm'}, | 
					
						
							|  |  |  |         {id: 2, name: 'Superman'} | 
					
						
							|  |  |  |       ]; | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     activate: function() { | 
					
						
							|  |  |  |       this.heroCmps.forEach(function(cmp) { | 
					
						
							|  |  |  |         cmp.activate(); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   // #enddocregion view
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   app.HeroesQueriesModule = | 
					
						
							|  |  |  |     ng.core.NgModule({ | 
					
						
							|  |  |  |       imports: [ ng.platformBrowser.BrowserModule ], | 
					
						
							|  |  |  |       declarations: [ | 
					
						
							|  |  |  |         AppComponent, | 
					
						
							|  |  |  |         HeroComponent, | 
					
						
							|  |  |  |         ActiveLabelComponent | 
					
						
							|  |  |  |       ], | 
					
						
							|  |  |  |       bootstrap: [ AppComponent ] | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .Class({ | 
					
						
							|  |  |  |       constructor: function() {} | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | })(window.app = window.app || {}); |