gon250
gon250

Reputation: 3545

Show break lines ( ) properly

I have a list of objects where one of the properties is description and the value has break lines as  .

I'm using the normal way to print it in my HTML, take a look below:

<div class="row" *ngFor="let item of items">
   <p>{{item.description}}</p>
</div>

and in the result I can't see the break line, What I see is the description as below:

line 1 `&nbsp;` line 2 `&nbsp;` line 3 

and should be something like:

line 1
line 2
line 3

Any idea how to solve it?

Upvotes: 0

Views: 5323

Answers (1)

Rub&#233;n Soler
Rub&#233;n Soler

Reputation: 1187

The &nbsp is an ISO character, same as space you shouldn't use it to write break lines.

You can use the <br> tag and in the binding, use [innerHTML] ="ítem.description".

Upvotes: 6

Related Questions