| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | import { | 
					
						
							|  |  |  |   Attribute, | 
					
						
							|  |  |  |   Component, | 
					
						
							|  |  |  |   ElementRef, | 
					
						
							|  |  |  |   Inject, | 
					
						
							|  |  |  |   Optional, | 
					
						
							|  |  |  |   Query, | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   QueryList, | 
					
						
							|  |  |  |   NgModule | 
					
						
							| 
									
										
										
										
											2016-04-27 11:28:22 -07:00
										 |  |  | } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | import { BrowserModule } from '@angular/platform-browser'; | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // #docregion
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'hero-title', | 
					
						
							|  |  |  |   template: `
 | 
					
						
							|  |  |  |     <h1>{{titlePrefix}} {{title}}</h1> | 
					
						
							|  |  |  |     <button (click)="ok()">OK</button> | 
					
						
							|  |  |  |     <ng-content></ng-content> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | class TitleComponent { | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |   constructor( | 
					
						
							|  |  |  |     @Inject('titlePrefix') | 
					
						
							|  |  |  |     @Optional() | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |       private titlePrefix: string, | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |     @Attribute('title') | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |       private title: string, | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |     @Query('okMsg') | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |       private msg: QueryList<ElementRef>) { | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ok() { | 
					
						
							|  |  |  |     let msgEl = | 
					
						
							|  |  |  |       this.msg.first.nativeElement; | 
					
						
							|  |  |  |     msgEl.textContent = 'OK!'; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'hero-di-inject-additional', | 
					
						
							|  |  |  |   template: `<hero-title title="Tour of Heroes">
 | 
					
						
							|  |  |  |     <span #okMsg class="ok-msg"></span> | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   </hero-title>` | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | class AppComponent { } | 
					
						
							| 
									
										
										
										
											2016-03-16 18:01:33 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | @NgModule({ | 
					
						
							|  |  |  |   imports: [ BrowserModule ], | 
					
						
							|  |  |  |   declarations: [ | 
					
						
							|  |  |  |     AppComponent, | 
					
						
							|  |  |  |     TitleComponent | 
					
						
							|  |  |  |   ], | 
					
						
							|  |  |  |   bootstrap: [ AppComponent ] | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | export class HeroesDIInjectAdditionalModule { } |