2

Using Angular 4 - the following snippet of code resides in my typescript file.

this.tabTitle = "Project Name: " + this.currentProjectRevision.ProjectInformation[0].ProjectName;

this grabs the value of the project name and concatenates it with Project name:

       this.tabTitle = this.tabTitle.concat('/n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

The above code grabs the first line of codes values and concatenates it with Quote ID: and adds the value of the Quote ID.

When running this, the output is as follows. Project Name: test /n Quote ID: 0000001

The actual value stated above gets appended into the following code. Project Name: bvn xbn/n Quote ID: 1000016

I would like to have quote ID start on a new line. I have tried putting in <br/>, <br> as well as /n will no success. They are all being added as a string.

Code I have tried so far

this.tabTitle = this.tabTitle.concat('<br/>' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

this.tabTitle = this.tabTitle.concat('<br>' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

this.tabTitle = this.tabTitle.concat('/n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId);

Any help will be greatly appreciated.

1
  • Show us how you declare tabTitle and how you use it in the HTML markup. Commented May 23, 2018 at 20:53

2 Answers 2

5

You can attach a class to the element with the attribute white-space: pre;. This will break it into a new line for you if you're using /n.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this was the 2nd part of the answer. Greatly Appreciated.
2

It seems that .concat() follows its own rules. I tested it myself to find out that every line break operator gets ignored.

If you are not bound to using concat(), simply use the '+' operator instead. It proceeds an implicit concatenation.

Try it this way:

this.tabTitle += '\n' + " Quote ID: " + this.quoteInformation.CurrentProjectCustomer.QuoteId;

3 Comments

Sorry I forgot to add the ticks to the break tags, I have tried this prior and it was adding it in as a string.
PS: If this answer helped you, it would be kind if you would mark it as solution.
Thank you for your help, this helped add the break but wasn't showing the actual line break. Needed to add white-space: pre in order for the css to actually show the break!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.