2

I'm getting some text from a database, which comes from a text editor. So it can have styling or lay-out (read: bold text, line breaks, etc). An example of the text:

hallo<br>wereld<br>

Without entities it looks like:

hallo<br>wereld<br>

How can i put this in a contenteditable div so that it looks like this:

hallo

wereld

Preferably an answer in Angular2 context, though a correct answer is also aprreciated in plain JS.

Edit:

<div #contentEditable contenteditable="true" cvContenteditableModel [model]="getContent()" (modelChange)="setContent()" autofocus></div>
Community
  • 1
  • 1
Martijn van den Bergh
  • 1,434
  • 1
  • 20
  • 40
  • 1
  • Possible duplicate of [angular 2 html binding](https://stackoverflow.com/questions/31548311/angular-2-html-binding) – Claies Sep 06 '17 at 07:30
  • unescape (https://www.w3schools.com/jsref/jsref_unescape.asp) and innerHTML – Carsten Sep 06 '17 at 07:30
  • I added my html code from my Angular 2 project. I'm working with a directive on the div that is contentEditable. Therefor i use the `@Input` and `@Output` of the directive. Adding innerHTML messes up the behavior of the contenteditable, like always putting the caret in front every time i press a key. Could u provide an answer in this context? I know it's not easy but i would greatly appreciate it. – Martijn van den Bergh Sep 06 '17 at 09:06

0 Answers0