There is such a html:

<div ng-bind-html="textCtrl.text"></div> 

This is a simple <div> container in which the html text is located.

  • The chain of actions that I need to implement:
    1. User selects text with the mouse
    2. Press the right button, and in the context menu (already implemented) selects Mark
    3. I save the selection position in the database, and change the background color under this selection
    4. I update the page
    5. I get the selection position from the database and restore it after the page loads

My problem begins with point # 3, I don’t understand how I can save the selection position and then select this text again in the exact place, for example after updating the page, or if I want to use this div in another place (a pop-up window for example).

How can it be possible to get the offset from the beginning of this div and then somehow restore this selection on this offset, or how to do it correctly?

0