From 6193d1f4a87c8a51d407a794034201c7e08f5b3e Mon Sep 17 00:00:00 2001 From: Kenta420 Date: Wed, 4 Oct 2023 14:34:01 +0700 Subject: [PATCH] add clock in navber header ; --- .../src/app/core/layout/layout.component.html | 6 +++-- .../src/app/core/layout/layout.component.ts | 22 ++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/client/src/app/core/layout/layout.component.html b/client/src/app/core/layout/layout.component.html index 285b7ba..5385042 100644 --- a/client/src/app/core/layout/layout.component.html +++ b/client/src/app/core/layout/layout.component.html @@ -34,11 +34,13 @@
-
+
- {{ date | date : "dd MMM yyyy" }} + {{ date | date : "dd MMM yyyy HH:mm:ss" }}

(); @@ -42,6 +43,21 @@ export class LayoutComponent implements OnInit { this._userService.currentUser .pipe(takeUntil(this.exit$)) .subscribe((user) => (this.user = user)); + + this.clockSubscription = timer(0, 1000) + .pipe( + map(() => new Date()), + share() + ) + .subscribe((time) => { + this.date = time; + }); + } + + ngOnDestroy() { + this.exit$.next(); + this.exit$.complete(); + this.clockSubscription?.unsubscribe(); } logout() {