how to make text able to copy in ionic App

Issue

i want to make a text able to copy in ionic App. i have tried this How to allow copy and paste from an ionic webview? solution. but it didn’t work for me. please could any suggestion me a solution.

Solution

Try applying these styles.

In your CSS file:

ion-content{
  overflow-scroll: true;
}

.scroll-content {
  -webkit-user-select: auto !important;
  -moz-user-select: auto !important;
  -ms-user-select: auto !important;
  user-select: auto !important;}

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

In your Controller

 stop_browser_behavior: false
  
self.touchStart = function(e) {
  self.startCoordinates = getPointerCoordinates(e);

  if ( ionic.tap.ignoreScrollStart(e) ) {
    return;
  }

  if( ionic.tap.containsOrIsTextInput(e.target) ) {
    // do not start if the target is a text input
    // if there is a touchmove on this input, then we can start the scroll
    self.__hasStarted = false;
    return;
  }

  self.__isSelectable = true;
  self.__enableScrollY = true;
  self.__hasStarted = true;
  self.doTouchStart(e.touches, e.timeStamp);
  // e.preventDefault();
};

Then in your HTML:

<div class='selectable'>
      This text should be selectable
</div>

Answered By – sunil kalwani

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published