9

I am using ionic and cordova to build a hybrid application.

However, I can't copy text from any of my webviews. From my Android phone or from the browser, copying text does not work. Selecting text and dragging the pointer does nothing.

This occurs for instance with the basic app generated by ionic start myApp tabs.

Simply put, how can I allow users to copy-paste?

Matt
  • 800
  • 1
  • 7
  • 15

3 Answers3

12

Make ion-content to overflow-scroll="true" and add a class to your copyable text

.selectable{
    -webkit-user-select: auto;
}

You cannot copy anything to clipboard from javascript for now programmatically. However it can be done from native side via plugin CordovaClipboard

engincancan
  • 2,442
  • 2
  • 28
  • 43
  • Fast forward to 2016 and [you **can** copy to clipboard from javascript](https://developers.google.com/web/updates/2015/04/cut-and-copy-commands?hl=en) with `document.execCommand('copy')` (but the text has to be selectable first, with `-webkit-user-select: text` or similar) – jakub.g Jun 02 '16 at 15:14
0

.selectext
{
  -webkit-user-select: auto;
}
 <div class="selectext">
  Select text
  </div>
Supriya
  • 481
  • 5
  • 5
-4

You can try with console.log() and copy/paste from the console.

Or if you need to copy from an emulator you can use Remote debugging

lukabers
  • 189
  • 2
  • 11
  • Thanks, but I want to allow the user to copy-paste with a long click. I don't have a personal need to copy-paste. – Matt Nov 27 '14 at 09:51