Why does angular ng-bind not read \n line breaks from JSON? Why does angular ng-bind not read \n line breaks from JSON? json json

Why does angular ng-bind not read \n line breaks from JSON?


It does. The issue is html doesn't display it because of the white-space default setting, change your div to this:

<div ng-bind="textFromJSON" style="white-space:pre-wrap"></div>

See https://jsfiddle.net/xtqe7on2/ as an example


You can use <pre>

    <div><pre>{{textFromJSON}}</pre></div>


In Angular 2+ you can use like this:

<pre>{{textInJSON | json}}</pre>