convert new line /n to a line break in angular

in Angular you can easy convert text to the original format by entering it like so:

component:

this.myText = 'This is line one\nThis is line 2\nAnd here is 3'

html:

<div [innerText]='myText'></div>

This does not replace it, but you can use the CSS attribute white-space: pre-line; to render the \n in the browser: https://developer.mozilla.org/en-US/docs/Web/CSS/white-space

div {
  white-space: pre-line;
}
<div>Foo
   Bar
       Baz     Foo
     Bar
 


     
  Baz
</div>