Skip to content

Commit

Permalink
feat: copy to clipboard on load
Browse files Browse the repository at this point in the history
  • Loading branch information
Lovepreet Singh Jassal committed Jun 25, 2024
1 parent eabbb40 commit fca72d8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/components/unixtime/unixtime.component.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit fca72d8

Please sign in to comment.