Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 / TypeScript multi line string in Visual Studio Code

I am writing a custom component in Visual Studio Code and would like to assign a string value to a property. However I need to break the string into multiple lines. But whenever I do that VSCode gives me a list of problems.

This is what I am trying to achieve:

I can't break the string into multiple lines according to Visual Studio Code

like image 640
Arif Munaf Avatar asked Feb 06 '17 12:02

Arif Munaf


2 Answers

You need to use backTick to include multi line String literals. This is a feature of ES6

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals

like image 60
Parth Ghiya Avatar answered Sep 27 '22 20:09

Parth Ghiya


You can break lines using + concatening operator:

template: "<h1>" +
    "</h1>"

Or ` backtick

template: `<h1>
    </h1>`

Or \ backslash

template: "<h1>\
    </h1>"
like image 42
Magicprog.fr Avatar answered Sep 27 '22 19:09

Magicprog.fr