From fca72d8688b9b06a120dca85cb30136f02e56d91 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Jassal Date: Mon, 24 Jun 2024 21:44:52 -0400 Subject: [PATCH] feat: copy to clipboard on load --- src/app/components/unixtime/unixtime.component.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/components/unixtime/unixtime.component.ts b/src/app/components/unixtime/unixtime.component.ts index 5c05dac..1800c34 100644 --- a/src/app/components/unixtime/unixtime.component.ts +++ b/src/app/components/unixtime/unixtime.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { MatInputModule } from '@angular/material/input'; import { FormsModule } from '@angular/forms'; +import { Clipboard } from '@angular/cdk/clipboard'; @Component({ selector: 'app-unixtime', standalone: true, @@ -14,12 +15,17 @@ export class UnixtimeComponent implements OnInit { time = ""; utc = ""; + constructor(private clipboard: Clipboard){} + ngOnInit() { let date = Date.now(); this.unixtime = date; this.changed(); + this.clipboard.copy(this.unixtime.toString()); } + + changed() { let date = new Date(this.unixtime); this.date = date.toDateString();