jeff
jeff

Reputation: 3327

wrapping text in an angular interpolated binding

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?

Upvotes: 2

Views: 428

Answers (2)

Kaustubh Badrike
Kaustubh Badrike

Reputation: 565

For hello\r\nworld, you can add

p {
  white-space: pre;
}

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

Upvotes: -1

bgibers
bgibers

Reputation: 200

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

Upvotes: 3

Related Questions