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