Last active
April 15, 2020 19:58
-
-
Save FFKL/a19e85adc372f7da6b91fb3f3cc511f6 to your computer and use it in GitHub Desktop.
Single-file clock for admin panel header
This file contains hidden or 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 { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core'; | |
| import { timer, Observable } from 'rxjs'; | |
| import { map } from 'rxjs/operators'; | |
| @Component({ | |
| selector: 'app-clock', | |
| template: `{{ time$ | async | date:'medium' }}`, | |
| encapsulation: ViewEncapsulation.None, | |
| changeDetection: ChangeDetectionStrategy.OnPush | |
| }) | |
| export class ClockComponent { | |
| time$: Observable<Date> = timer(0, 1000).pipe( | |
| map(() => new Date()) | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment