2

I'd like to do something like this, where I'm trying to keep the line breaks that I have in the data.

<div>    
   <p> {{outputline}} </p>
</div>

where outputline is hello\r\nworld or hello<br>world

Both of which I've tried. I can do it in a more complex way with outputline1, outputline2, etc.

Any suggestions?

jeff
  • 3,269
  • 3
  • 28
  • 45
  • Does this answer your question? [Preserve line breaks in angularjs](https://stackoverflow.com/questions/19684708/preserve-line-breaks-in-angularjs) – Ramana Feb 29 '20 at 05:08

2 Answers2

3

Try <p [innerHTML]="outputline"></p>

bgibers
  • 200
  • 10
-1

For hello\r\nworld, you can add

p {
  white-space: pre;
}

in you css, or <pre> instead of <p> in your template.

Kaustubh Badrike
  • 495
  • 1
  • 4
  • 18