maxisam / ngx-clipboard

A pure angular clipboard directive
http://maxisam.github.io/ngx-clipboard/
MIT License
505 stars 93 forks source link

copy not working with Microsoft Edge #237

Open maerni opened 4 years ago

maerni commented 4 years ago

Hi

We use ngx-clipboard with the following code to copy something to clipboard:

public copyToClipboard(text: string) { if (this.clipboardService.isSupported && this.clipboardService.isCopySuccessInIE11()) { this.clipboardService.copyFromContent(text); } else { } }

We use ngx-clipboard 12.2.1 with Angular 7.2.15.

With Microsoft Internet Exporer 11 and Google Chrome it works fine.

With Microsoft Edge it does not work.

What we have to do?

Thanks very much.

maxisam commented 4 years ago

what version of edge? it works on my edge.

maerni commented 4 years ago

We use the following version

Microsoft Edge 42.17134.1098.0 Microsoft EdgeHTML 17.17134

Perhaps we use the wrong version of ngx-clipboard?

Should we use a 11.x version with Angular 7.x?

Or is our code wrong?

maxisam commented 4 years ago

Oh, i don't have version 42.

I am on Version 80.0.361.62

maerni commented 4 years ago

On another machine I have Microsoft Edge 44.18362.449.0 there it also did not work.

Then I downloaded Microsoft Edge 80.0.361.62. With this version it works.

But do have any idea, why it does not work with the old edge? Because in our company on all machines the version 42.x is installed...

maxisam commented 4 years ago

Do you have any error message in console?

maerni commented 4 years ago

no, the call

this.clipboardService.copyFromContent(text);

returns false but there is no error message

maxisam commented 4 years ago

I just tested it on browserstack. It works on Edge 18, which is version 44.

maxisam commented 4 years ago

But seriously, I doubt there are lots of people use Edge 18 anyway. Upgrading Edge seems like a good idea.

maerni commented 4 years ago

Did you also test it with version 42?

maerni commented 4 years ago

Very special. I tryed my application on Edge 17 (version 42) and Edge 18 (version 44) on browserstack and it did not work...

Perhaps we use ngx-clipboard wrong?

How would you use it for copying over the ClipboardService?

maxisam commented 4 years ago

You can check the example. https://stackblitz.com/github/maxisam/ngx-clipboard

I used angular 9 to test it. However, there are not much different after 11.x.

maxisam commented 4 years ago

I doubt you use it wrong because you said it works on IE 11.

maerni commented 4 years ago

Which version of ngx-clipboard should we use with Angular 7.x?

I will check your example and look, if we do something wrong.

maerni commented 4 years ago

I could not find any difference to your code.

In app.module.ts I have the following code:

import { ClipboardModule } from 'ngx-clipboard'; imports: [...ClipboardModule...],

In my component (it is a service) I have the following code:

import { ClipboardService } from 'ngx-clipboard'; constructor(private clipboardService: ClipboardService) {}

this.clipboardService.copyFromContent('blablabla');

maxisam commented 4 years ago

v12 should be able to work with angular 7. But I doubt that is the problem.

maerni commented 4 years ago

Very special