| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  | // Version #2
 | 
					
						
							| 
									
										
										
										
											2015-11-25 17:44:48 -08:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  | import {Component} from 'angular2/core' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 |  |  |   selector: 'hero-birthday2', | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  | // #docregion template
 | 
					
						
							| 
									
										
										
										
											2015-11-02 00:28:38 -08:00
										 |  |  |   template: `
 | 
					
						
							|  |  |  |     <p>The hero's birthday is {{ birthday | date:format }}</p> | 
					
						
							|  |  |  |     <button (click)="toggleFormat()">Toggle Format</button> | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  |   `
 | 
					
						
							|  |  |  | // #enddocregion template
 | 
					
						
							| 
									
										
										
										
											2015-11-02 00:28:38 -08:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  | // #docregion class
 | 
					
						
							| 
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 |  |  | export class HeroBirthday2 { | 
					
						
							| 
									
										
										
										
											2015-11-02 00:28:38 -08:00
										 |  |  |   birthday = new Date(1988,3,15); // April 15, 1988
 | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  |   toggle = true; // start with true == shortDate
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 |  |  |   get format()   { return this.toggle ? 'shortDate' : 'fullDate'} | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  |   toggleFormat() { this.toggle = !this.toggle; } | 
					
						
							| 
									
										
										
										
											2015-11-02 00:28:38 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  | // #enddocregion class
 |