TypeScript - How to append line break (n) on string?

Multi tool use
Multi tool use


TypeScript - How to append line break (n) on string?



I'm trying to concatenate a string with a "n" like this:


- Item 1
- Item 2


var msg: string = '';
msg += '- Campo NOME é obrigatório';
msg += "n- Campo EMAIL é obrigatório";



But the output comes without the line break:


- Item 1 - Item 2



I searched a lot about it but I didn't find a solution. Could you please help me? :)




1 Answer
1



If you rendering to HTML, you will want to use the HTML tag for a newline :



The string HellonnTest in your source will look like this:


HellonnTest


Hello!

Test



The string Hello<br><br>Test will look like this in HTML source:


Hello<br><br>Test


Hello<br><br>Test



Try this :


var msg: string = "";
msg += "- Campo NOME é obrigatório";
msg += "<br/>- Campo EMAIL é obrigatório";



Here is fiddle : https://jsfiddle.net/9fuxgbms/1/






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

cuZI0kQeIXzRz8TiRofmME7yOo7CEHCc,T,Day,JXxGan
Hz8ZK9lRqMhE,hdIFP33GeQJyAGHSJWswrYS uIxa9zAl6lkg3

Popular posts from this blog

PySpark - SparkContext: Error initializing SparkContext File does not exist

django NoReverseMatch Exception

List of Kim Possible characters