⚡ component to copy text to clipboard
This commit is contained in:
parent
bc67f26327
commit
63e1a5e899
|
@ -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 >
|
|
@ -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();
|
||||||
|
});
|
||||||
|
});
|
|
@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue