Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render newlines in NoSQL data with a web browser?

How have a long string and would like to seperate some of the text with a newline.

it seems \n or \n does not work or

What is in database:

description: "Hello \n world"

When I retrieve the data I get

Hello world

Instead of:

Hello

World

like image 901
Doopler Avatar asked May 13 '16 05:05

Doopler


1 Answers

Wrap content in <pre> tag, so that will get formatted correctly on view.

<pre>{{description}}</pre>

Demo Here


Other options is to use ng-bind-html directive + add ngSanitize module in app depenency

<p ng-bind-html="description"></p>

Plunkr

like image 133
Pankaj Parkar Avatar answered Oct 23 '22 12:10

Pankaj Parkar