Skip to content

Instantly share code, notes, and snippets.

@FFKL
Last active April 15, 2020 19:58
Show Gist options
  • Select an option

  • Save FFKL/a19e85adc372f7da6b91fb3f3cc511f6 to your computer and use it in GitHub Desktop.

Select an option

Save FFKL/a19e85adc372f7da6b91fb3f3cc511f6 to your computer and use it in GitHub Desktop.
Single-file clock for admin panel header
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