Reputation: 978
I am working on Angular2 in which i need to create a new line for my dynamically created string.
eg.
input:
Hello how are you ?
output:
Hello
how
are
you?
Here is my code:
.html
<div class="row">
<div class="well">
<h1 class="text-center">Import Data</h1>
<p class="text-center">{{selectedLogContent.message}}</p>
</div>
</div>
this is 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 tried using '\n' while concatenation of the string still ending up the output in the same line.
Thanks in advance
Upvotes: 2
Views: 7321