| 
									
										
										
										
											2015-11-25 17:44:48 -08:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02:00
										 |  |  | import { Component } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-12-12 22:01:46 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Component({ | 
					
						
							| 
									
										
										
										
											2016-01-13 15:00:43 -07:00
										 |  |  |   selector: 'hero-birthday2', | 
					
						
							| 
									
										
										
										
											2016-05-13 13:44:14 -07: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
										 |  |  |   `
 | 
					
						
							| 
									
										
										
										
											2016-05-13 13:44:14 -07: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 { | 
					
						
							| 
									
										
										
										
											2016-06-08 01:06:25 +02: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-06-08 01:06:25 +02: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
										 |  |  | } |