Search code examples
angularjsrangy

Restore Text Selection from a Range


I have a range object created by Rangy in Javascript. Now i want to Restore the text from this Range object.

E.g range= WrappedRange {nativeRange: Range, commonAncestorContainer: div.ng-scope, collapsed: false, endOffset: 19, endContainer: text…}

Need help with how can i do it ...?


Solution

  • I think you need

    var sel = rangy.getSelection();
    sel.setSingleRange(range);