0

I was expecting the message to be displayed in two different lines. How do I use <br/> tag to split the lines in Typescript?

TS code

  posts = {
    social: {
      title: "test",
      message: `test message \n
      test message`
    }
  };

HTML

<div>
  {{posts.social.message}}
</div>

I created a working example using CodeSandbox. Could anyone please help?

scriobh
  • 868
  • 10
  • 25
  • Doesn't work how? Given that HTML will typically ignore some white space. What is not working? – Taplar Nov 18 '20 at 23:56
  • @Taplar I was expecting message to be displayed in two different lines – scriobh Nov 18 '20 at 23:57
  • You're building out html. You either need to use
    or

    tags or the like, or style your div with `white-space: pre`

    – Taplar Nov 18 '20 at 23:57
  • 4
    Does this answer your question? [How to get line break within string interpolation in Angularjs](https://stackoverflow.com/questions/47678148/how-to-get-line-break-within-string-interpolation-in-angularjs) – yi fan song Nov 19 '20 at 00:03
  • Yes, that answers my question. @yifansong – scriobh Nov 19 '20 at 00:05

0 Answers0