What is the best way to handle linebreaks from JSON?
When saving data from a TextArea to JSON, the linebreaks are \n
When rendered back in html, the linebreaks do not work.
Using <pre></pre> tags makes it work but removes formatting.
<pre>{{sometextdata}}</pre>
I could add fonts to the <pre> in scss but this seems like it may not be the best/easiest way to handle this.
Any Ionic2 options?
If using the <pre> tags are the way to go - what is the default font ionic2 uses so I can push this back to the <pre> tags?
{{textWithLineBreaks}} does not produce the linebreak.
Here is an example of the text saved in JSON from a TextArea:
{“description”:“One Two Three\nFour Five Six”}
Note the \n
When I used the following: textWithLineBreaks = textWithLineBreaks.replace(/\\n/g, '<br \/>')
It does not work.
However this does: textWithLineBreaks = textWithLineBreaks .replace(/\n/g, '<br \/>')
This does do as you mention though - display the <br />
So I used the <div [innerHtml]="test2"></div>
So while this ultimately works, it seems that there must be a better way.
Maybe the way I am saving the JSON from the TextArea?