Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Line '\n' is not working in Typescript

I am creating a list item in typescript component which will be displayed in the UI. The List items should be displayed in separate lines. So i added new line char \n as below. But still the list items are shown in same line. Below is the code. Any idea why it doesn't work?

UI Display of ul list

Typescript Code:

@Output() excludeDisplay: any = '';
@Output() includeDisplay: any = '';
includeValues: any = '';
excludeValues: any = '';

this.includeValues += this.merId + ',' + this.explodeStatus + '\n';
console.log("include values are "+ this.includeValues);
this.excludeValues += this.merId + ',' + this.explodeStatus + '\n';
console.log("exclude values are "+ this.excludeValues);
this.includeDisplay = this.includeValues;
this.excludeDisplay = this.excludeValues;

Html Code:

<ul id="excludedUl" required>{{ excludeDisplay }}</ul>
<ul id="includedUl" required>{{ includeDisplay }}</ul>

CSS Code:

#includedUl {
  float: right;
  width: 33%;
}

#excludedUl {
  float: right;
  width: 33%;
}
like image 456
Poonkodi Sivapragasam Avatar asked Jun 25 '17 06:06

Poonkodi Sivapragasam


People also ask

How do you insert a new line in typescript?

In typescript use '\n' to add new line.

Is it n or \n for new line?

Operating systems have special characters denoting the start of a new line. For example, in Linux a new line is denoted by “\n”, also called a Line Feed. In Windows, a new line is denoted using “\r\n”, sometimes called a Carriage Return and Line Feed, or CRLF.

Does \n work in R?

The most commonly used are "\t" for TAB, "\n" for new-line, and "\\" for a (single) backslash character.

What is \n HTML?

The \n character matches newline characters.


1 Answers

Need to use fix width:

 <div style="width: 500px;white-space: pre-line">{{property}}</div>

In typescript use '\n' to add new line.

like image 172
Palash Roy Avatar answered Sep 18 '22 12:09

Palash Roy