import { Component, Input } from '@angular/core'; import { I18nService } from '@yourcause/common/i18n'; import { NotifierService } from '@yourcause/common/notifier'; @Component({ selector: 'gc-api-key-copy', templateUrl: './api-key-copy.component.html', styleUrls: ['./api-key-copy.component.scss'] }) export class ApiKeyCopyComponent { @Input() apiKey: string; constructor ( private i18n: I18nService, private notifier: NotifierService ) { } copyApiKey () { const el = document.createElement('textarea'); el.value = this.apiKey; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); this.notifier.success(this.i18n.translate( 'common:textSuccessfullyCopiedToClipboard', {}, 'Successfully copied to clipboard.' )); } }