B1NARY
B1NARY

Reputation: 163

New line and tabs being added to my string in angular

I have the following div in my html:

<div flex style="white-space:pre-wrap;">
    {{c.display}}
</div>

c.display is set like so:

$scope.c.display = "foo\nbar\n\tfoobar";

The output looks like so:

enter image description here

The html source looks like this:

enter image description here

If I change the source on Chrome using the dev tools to this:

enter image description here

I get what I wanted the whole time, which is this:

enter image description here

So, why is this happening and how can I make it stop?

Upvotes: 0

Views: 546

Answers (1)

Adeel Zafar Soomro
Adeel Zafar Soomro

Reputation: 1522

How about removing white-space from within the div?

<div flex style="white-space:pre-wrap;">{{c.display}}</div>

Upvotes: 1

Related Questions