| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  | // #docplaster
 | 
					
						
							|  |  |  | // #docregion
 | 
					
						
							|  |  |  | // #docregion imports
 | 
					
						
							| 
									
										
										
										
											2016-06-03 18:00:53 +02:00
										 |  |  | import { Component, Inject } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  | import { APP_CONFIG, AppConfig }    from './app.config'; | 
					
						
							|  |  |  | import { Logger } from './logger.service'; | 
					
						
							| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  | import { UserService } from './user.service'; | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  | // #enddocregion imports
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  |   selector: 'my-app', | 
					
						
							|  |  |  |   template:  `
 | 
					
						
							|  |  |  |     <h1>{{title}}</h1> | 
					
						
							|  |  |  |     <my-car></my-car> | 
					
						
							|  |  |  |     <my-injectors></my-injectors> | 
					
						
							|  |  |  |     <my-tests></my-tests> | 
					
						
							|  |  |  |     <h2>User</h2> | 
					
						
							|  |  |  |     <p id="user"> | 
					
						
							|  |  |  |       {{userInfo}} | 
					
						
							|  |  |  |       <button (click)='nextUser()'>Next User</button> | 
					
						
							|  |  |  |     <p> | 
					
						
							|  |  |  |     <my-heroes id="authorized" *ngIf="isAuthorized"></my-heroes> | 
					
						
							|  |  |  |     <my-heroes id="unauthorized" *ngIf="!isAuthorized"></my-heroes> | 
					
						
							|  |  |  |   `,
 | 
					
						
							| 
									
										
										
										
											2016-08-09 17:38:25 +01:00
										 |  |  |   providers: [Logger] | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  | }) | 
					
						
							|  |  |  | export class AppComponent { | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   title: string; | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-03 11:16:46 -07:00
										 |  |  |   // #docregion ctor
 | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  |   constructor( | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |     @Inject(APP_CONFIG) config: AppConfig, | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     private userService: UserService) { | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  |     this.title = config.title; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion ctor
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |   get isAuthorized() { return this.user.isAuthorized; } | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   nextUser()         { this.userService.getNewUser(); } | 
					
						
							|  |  |  |   get user()         { return this.userService.user; } | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   get userInfo()     { | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  |     return `Current user, ${this.user.name}, is ` + | 
					
						
							| 
									
										
										
										
											2016-01-11 13:49:12 +01:00
										 |  |  |            `${this.isAuthorized ? '' : 'not'} authorized. `; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |