0

I am using Angular2 and ngx-clipboard and am trying to copy the html content in a div:

<div>
    <div>
        <div #instr class="instructions" innerHTML="{{ 'somtext' | translate }}"></div>              
    </div>
    <div class="xxx">
        <clipboard [value]="instructions.innerHTML"></clipboard>          
    </div>                                 
</div>

where sometext is an html string example,

"somtext"="<ol><li>abc...<b>qqq</b></li><li>def</li></ol> 

The problem is if I use instructions.innerHTML with clipboard and then tries to paste it somehwere, it prints all the html tags etc. If I use innerText, the tags are removed which is good but then it also loses the numbering I get from using order list tags. I want to retain the numbering when I paste the content copied using ngx-clipboard on a notepad or something

How can I achieve this?

user1892775
  • 2,001
  • 6
  • 37
  • 58
  • don't use ordered lists, add the index manually – smnbbrv Jan 02 '18 at 23:21
  • I did consider that option. But the issue with that is that the second line of a particular index starts from right below the index number. I would want that to start from the same position as the text after the number on the first line. Do you know if I can achieve that when using index manually? – user1892775 Jan 02 '18 at 23:24
  • I think you have too many requirements (and will have many more) for what you've been given with. Taking the text is a good option but it is totally not configurable and you won't be able to do the customisations that easily. You probably should take the HTML as an entry point and convert it to whatever you want. – smnbbrv Jan 02 '18 at 23:27

0 Answers0