0

I am trying to add a new line to a string in Angular application. In component.ts file I have added a variable which takes a string value.

heading="Lorem ipsum dolor sit amet. \n consetetur sadipscing elitr."

In component.html file I am calling this variable.

<div>{{heading}}</div>

But no new line is generated and the text is one single paragraph. Can someone help me with this.

roger king
  • 147
  • 1
  • 2
  • 10

1 Answers1

2

Try to add CSS style to to that Div.

div{
white-space:pre-line;
}

It should render \n in the browser.

Pinnci
  • 423
  • 2
  • 5
  • 20