Created
August 9, 2017 19:32
-
-
Save premsh/eb0bf459d913d307fef7fbef12909f0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from '@angular/core'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Subject } from 'rxjs/Subject'; | |
import 'rxjs/add/observable/interval'; | |
import 'rxjs/add/operator/map'; | |
import 'rxjs/add/observable/merge'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { | |
clock: Observable<any>; | |
clock$ = new Subject(); | |
constructor() { | |
this.clock = Observable.merge(this.clock$, | |
Observable.interval(3000)) | |
.map(() => new Date()); | |
} | |
} | |
// html part | |
{{ clock | async | date: 'medium' }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment