TypeScript - Angular: Multiline string
Wrap the text in `
(backticks) instead of single quotes '
, then it can span multiple lines.
var myString = `abc
def
ghi`;
the accepted answer works only if we want \n added in our string , if we just want content to be on newline without adding \n in the long string , please add \ at the end of every line like this
string firstName = `this is line 1 \
and this is line 2 => yet "new line" are not \
included because they were escaped with a "\"`;
console.assert(firstName == 'this is line 1 and this is line 2 => yet "new line" are not included because they were escaped with a "\"'); // true
Note - make sure you are not adding any tabs and spaces in the beginning of the next(second in the example) line