1

Im trying to get angularjs to read my new lines properly, in this case /n is a new line.

here is my acual response from my variable message with the info i would like to display:

jeg\n\nlurer\npaa hva

when i display the variable in the view with {{ message }}i get:

Jeg lurer paa hva

while it really should be:

Jeg

lurer
paa hva

how can i make angular read the /n as new line?

maria
  • 207
  • 5
  • 22
  • 56

4 Answers4

2

Use some css styling

  <div class="pre-line">{{message}}</div>

n in CSS

 div.pre-line {
      white-space: pre-line;
 }
Disha
  • 822
  • 1
  • 10
  • 39
1

Put your {{message}} inside a <pre> tag like,

<pre>{{message}}</pre>

which will take care of the link breaks.

Hope this helps!

David R
  • 14,711
  • 7
  • 54
  • 72
1

Are you looking for ng-bind-html?

Mov5
  • 51
  • 5
0

Adding <pre> tag around of your {{ message }} will resolve your problem. You can add this feature of the pre tag with css.

Ajeet Shah
  • 18,551
  • 8
  • 57
  • 87
hamid reza
  • 33
  • 8