Currently, I am delving into Angular2 and facing the challenge of creating a new line for my dynamically generated string.
For example:
input:
Hello how are you ?
output:
Hello
how
are
you?
Below is the code snippet:
.html
<div class="row">
<div class="well"gt;
<h1 class="text-center">Import Data</h1>
<p class="text-center">{{selectedLogContent.message}}</p>
</div>
</div>
This corresponds to the typescript code:
var splitString = selectedRows[0].description.split(":");
var messageString= splitString[3].split(".");
var messageStringAfter ="";
for(var i=0;i<messageString.length;i++){
messageStringAfter= messageStringAfter+`\
\n`+messageString[i];
}
var finalString = splitString[0]+":"+splitString[1]+":"+splitString[2]+': '+messageStringAfter;
console.log(finalString);
this.selectedLogContent.message = finalString;
I attempted to use '\n' during string concatenation, but couldn't achieve the desired output in separate lines.
Your help would be greatly appreciated! Thank you.