ngx-sharebuttons
ngx-sharebuttons copied to clipboard
Copy link button not working
Reproduction
Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/ngx-sharebuttons
Steps to reproduce:
- I have configure the ngx-sharebuttons
- set all required properties
- still copy button does not work.
- all other option works properly but copy button is not working.
I am using "11.0.0" version.
Expected Behavior
What behavior were you expecting to see? Copy button should work and link should be copy to clipboard.
Actual Behavior
What behavior did you actually see? Copy to clipboard button do nothing. all other button works as expected.
Environment
- Angular: 14
- ngx-sharebuttons: v11
- Browser(s): Any
- Operating System (e.g. Windows, macOS, Ubuntu): Windows
Please add a reproduction, the live stackblitz works properly!
For me working as expected, but there is no indication - it will be great from the UX perspective to notify users when action is completed. @MurhafSousli is there any way to enable it?
@duxor You can subscribe to the opened
output when a share button is clicked, then display the notification you like!
@MurhafSousli great, thanks, I will check it in the next few days :)
@MurhafSousli , Unfortunately, the opened emitter doesn't work as expected for copy share type - I tested it using the share directive.
The copyToClipboard
util function will be called from [here] and there is no emitter, you can check the config [here] and util function [here].
So, what do you suggest? :)
@duxor I will look into why opened
is not emitting
Check the directive usage https://github.com/MurhafSousli/ngx-sharebuttons/wiki/Share-Button-Directive#usage
You can use the following:
<button shareButton="copy" #copy="shareButton" url="http://abc.com">
{{ copy.text }}
</button>
copy.text
will change when the copy button is clicked
You can also access the icon copy.icon
If you need an event, use the click event of the button
<button shareButton="copy" #copy="shareButton" url="http://abc.com" (click)="onCopyClick()">
{{ copy.text }}
</button>
Here is a working stackblitz
Here are the default properties of the copy button:
https://github.com/MurhafSousli/ngx-sharebuttons/blob/ac059e97774feeef3bec5d2facb73e2fc1f23192/projects/ngx-sharebuttons/src/lib/share.defaults.ts#L249-L262
@MurhafSousli
thanks for your reply but i use the same code as you copy text changes and working good but i don't get any value it still empty value nothing copied to clipboard
this is my code
` <ng-template #shareButtons> <share-buttons [theme]="'circles-dark'" [include]="include" [title]="title" [description]="title" [image]="image" [tags]="tags" [url]="url">
<button shareButton="copy" #copy="shareButton" [url]="url"> {{ copy.text }} `