I want to have a date countdown like this:
http://codepen.io/garethdweaver/pen/eNpWBb
but in angular 2, I found this plunkr that adds 1 to a number each 500 miliseconds:
https://plnkr.co/edit/pVMEbbGSzMwSBS4XEXJI?p=preview
this is the code:
import {Component,Input} from 'angular2/core';
import {Observable} from 'rxjs/Rx';
@Component({
selector: 'my-app',
template: `
<div>
{{message}}
</div>
`
})
export class AppComponent {
constructor() {
Observable.interval(1000)
.map((x) => x+1)
.subscribe((x) => {
this.message = x;
}):
}
}
But I want to have a date taking one second until reach 0.
See Question&Answers more detail:os