| 
									
										
										
										
											2016-04-10 09:14:24 -04:00
										 |  |  | // #docplaster
 | 
					
						
							|  |  |  | // #docregion
 | 
					
						
							|  |  |  | // Import the native Angular services.
 | 
					
						
							| 
									
										
										
										
											2016-04-27 11:28:22 -07:00
										 |  |  | import { Component } from '@angular/core'; | 
					
						
							|  |  |  | import { Title }     from '@angular/platform-browser'; | 
					
						
							| 
									
										
										
										
											2016-04-10 09:14:24 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							|  |  |  | selector: 'my-app', | 
					
						
							|  |  |  | template: | 
					
						
							|  |  |  |   `<p>
 | 
					
						
							|  |  |  |     Select a title to set on the current HTML document: | 
					
						
							|  |  |  |   </p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   <ul> | 
					
						
							|  |  |  |     <li><a (click)="setTitle( 'Good morning!' )">Good morning</a>.</li> | 
					
						
							|  |  |  |     <li><a (click)="setTitle( 'Good afternoon!' )">Good afternoon</a>.</li> | 
					
						
							|  |  |  |     <li><a (click)="setTitle( 'Good evening!' )">Good evening</a>.</li> | 
					
						
							|  |  |  |   </ul> | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | // #docregion class
 | 
					
						
							|  |  |  | export class AppComponent { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   public constructor(private titleService: Title ) { } | 
					
						
							| 
									
										
										
										
											2016-04-10 09:14:24 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   public setTitle( newTitle: string) { | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |     this.titleService.setTitle( newTitle ); | 
					
						
							| 
									
										
										
										
											2016-04-10 09:14:24 -04:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | // #enddocregion class
 |