We can process selected text by user in browser window. We need to use window.getSelection or document.selection. In below example,  Mouse-Up event will be triggered when user selects the text, Then Angular function will process the selected text.

Markup

<div ng-mouseup="showSelectedText()">
Do you think that facebook, twitter...............
</div>
<div ng-bind="selectedText"></div>

Script

$scope.getSelectionText = function() {
      var text = "";
      if (window.getSelection) {
          text = window.getSelection().toString();
      } else if (document.selection && document.selection.type != "Control") {
          text = document.selection.createRange().text;
      }
      return text;
};

6 comments:

  1. Very nice, that's what I was looking for, thank you dude!

    ReplyDelete
  2. Very nice, that's what I was looking for, thank you dude!

    ReplyDelete
  3. Thanks a lot for the helpful post!

    ReplyDelete
  4. I love your creativity. Are you also searching for nursing writing services? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

    ReplyDelete

Blogroll

Popular Posts