component to copy text to clipboard

This commit is contained in:
Baptiste Lemoine 2020-02-04 11:35:09 +01:00
parent bc67f26327
commit 63e1a5e899
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<button
(click)='handleClick()'
[cbContent]="textToCopy"
[ngxClipboard]
class=" btn btn--primary btn--outline"
id="copyLink" >
<i class='fa fa-copy' ></i >
{{"admin.copy_link" |translate}} " {{ textToCopy}}"
</button >

View File

@ -0,0 +1,25 @@
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
import {CopyTextComponent} from './copy-text.component';
describe('CopyTextComponent', () => {
let component: CopyTextComponent;
let fixture: ComponentFixture<CopyTextComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [CopyTextComponent]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CopyTextComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,26 @@
import {Component, Input, OnInit} from '@angular/core';
import {MessageService} from "primeng/api";
@Component({
selector: 'framadate-copy-text',
templateUrl: './copy-text.component.html',
styleUrls: ['./copy-text.component.scss']
})
export class CopyTextComponent implements OnInit {
@Input() public textToCopy: any;
constructor(private messageService: MessageService,) {
}
ngOnInit() {
}
handleClick() {
this.messageService.add({
severity: 'success',
summary: 'Texte copié',
detail: this.textToCopy
})
}
}