ngx-clipboard icon indicating copy to clipboard operation
ngx-clipboard copied to clipboard

Using `copyFromContent` from `ClipboardService` does not give callback in `copyResponse$`

Open saranglakare opened this issue 4 years ago • 3 comments

From your documentation it seems that I should always get call back whenever a copy is successful. I am getting callbacks when copied using template modifications. But when I copy something using copyFromContent there seems to be no callback.

I tested on https://stackblitz.com/github/maxisam/ngx-clipboard as well and the alert is not displayed when Copy from Service button is clicked.

Am I missing something?

saranglakare avatar Aug 06 '20 09:08 saranglakare

Should use copy instead. I probably should deprecated copyFromContent. Thx

maxisam avatar Aug 06 '20 15:08 maxisam

Please consider reopening this. Sometimes we need to pass the container to the service, for instance if the content is copied from a modal. See the issue described here.

In my case I have an Angular app that uses an Ionic-based framework, and if the content resides in a modal I need to do something like this to get the copy functionality to work:

this.clipboard.copyFromContent(
  stringToCopy,
  document.querySelector('ion-modal') ?? undefined
);

KemalPajevic avatar Apr 28 '23 13:04 KemalPajevic

@KemalPajevic is the current behavior still working for you?

maxisam avatar Apr 29 '23 20:04 maxisam