2015-12-13 01:01:46 -05:00
|
|
|
// Version #2
|
2015-11-25 20:44:48 -05:00
|
|
|
// #docregion
|
2015-12-13 01:01:46 -05:00
|
|
|
import {Component} from 'angular2/core'
|
|
|
|
|
|
|
|
@Component({
|
2016-01-13 17:00:43 -05:00
|
|
|
selector: 'hero-birthday2',
|
2015-12-13 01:01:46 -05: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
|
|
|
`
|
|
|
|
// #enddocregion template
|
2015-11-02 03:28:38 -05:00
|
|
|
})
|
2015-12-13 01:01:46 -05:00
|
|
|
// #docregion class
|
2016-01-13 17:00:43 -05:00
|
|
|
export class HeroBirthday2 {
|
2015-11-02 03:28:38 -05: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-01-13 17:00:43 -05: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
|
|
|
}
|
2015-12-13 01:01:46 -05:00
|
|
|
// #enddocregion class
|