-3

I know I am revisiting an old problem but I hope there are new answers. I am using angular/Modal to display a paragraph from a .json file. I need to insert a newline for each paragraph when displayed in the browser. I have tried \n ,\r,
This is a sample of an entry:

"termsAndServiceContent": "1. TERMS OF USE: \n These Terms of Use (Terms) govern your access or use, from within the United States and its territories and possessions ...........\r <br/>   By accessing or using the Services, you confirm your agreement to be bound by these Terms........",

I expected to get a new line for the \n and \r but nothing happens. How can I get the browser to recognize the escape characters?

I guess the question is quite similar and I did mentioned that its an old issue. I really didn't see this

https://stackoverflow.com/questions/39325414/line-break-in-html-with-n

question before but I still don't believe the answers address my issue. I am not using plain HTML I am using Angular and my render code looks like this:

<a (click)="showTermAndServicesWindow($event)">{{LOCALIZATION.tos}}</a> 

where .tos is my .json file and that's all the HTML I want in the view....also I don't want to do any HTML templating in the .ts modules.

MichaelE
  • 757
  • 14
  • 42

1 Answers1

0

Use the HTML code <br> for new lines, and make sure you use <div [innerHTML]="theHtmlString"></div> to insert it as HTML.

Reactgular
  • 52,335
  • 19
  • 158
  • 208
  • your answer is not clear...I don't intend to mess with my .html or .ts files so where should i insert these changes? – MichaelE Jan 10 '18 at 04:18
  • @MichaelE you have to use the `innerHTML` binding to insert HTML into an Angular template. It's HTML because you can't use `\n` to insert line breaks. If you're looking for a different approach. You'll need to ask a different question. – Reactgular Jan 10 '18 at 13:58