Files
start-os/web/projects/shared/src/services/copy.service.ts
Alex Inkin a90b96cddd chore: update Taiga to 5 (#3136)
* chore: update Taiga to 5

* chore: fix
2026-03-15 09:51:50 -06:00

21 lines
701 B
TypeScript

import { inject, Injectable } from '@angular/core'
import { Clipboard } from '@angular/cdk/clipboard'
import { TuiNotificationService } from '@taiga-ui/core'
import { i18nPipe } from '../i18n/i18n.pipe'
@Injectable({ providedIn: 'root' })
export class CopyService {
private readonly clipboard = inject(Clipboard)
private readonly i18n = inject(i18nPipe)
private readonly alerts = inject(TuiNotificationService)
async copy(text: string) {
const success = this.clipboard.copy(text)
const message = success ? 'Copied to clipboard' : 'Failed'
const appearance = success ? 'positive' : 'negative'
this.alerts.open(this.i18n.transform(message), { appearance }).subscribe()
}
}