0

I have the following text, which is properly saved into database, and served back to browser:

Very very



long text

But in my angular application I get

Very very long text

<td [innerHTML]="client.text"></td> // doesn't work
<td>{{client.text}}</td> // doesn't work


// What I wish to achieve displayed into the browser:
Very very



long text
 

How am I able to achieve the consistency as above? I have a textarea which displays the text properly, however I wish to display it in a div/span/td element. Is this possible?

Ilia Hanev
  • 65
  • 7

1 Answers1

0

You can use pre tag to display the exact way it supposed to be.

As per HTML Documentation:

Text in a pre element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.

Try this:

<td><pre>{{client.text}}</pre></td>

Also you can do with css as well using white-space: pre-wrap., Check out this answer

<td style="white-space: pre-wrap;">{{ client.text }} </td>

Naren
  • 4,152
  • 3
  • 17
  • 28