Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  83] [ 1]  / answers: 1 / hits: 52748  / 8 Years ago, mon, april 4, 2016, 12:00:00

I have the following Angular2 TypeScript code with a section commented out as per Javascript convention:



@Component({
selector: 'my-app',
template:
`<h1>{{title}}</h1>
<h2>{{lene.name}}</h2>
<div><label>id: </label>{{lene.id}}</div>
/*<div>
<label>name: </label>
<input [(ngModel)]=lene.name placeholder=name>
</div>*/`
<div><label>description: </label>{{lene.description}}</div>
})


However, once the TypeScript compiles to Javascript I get the following output to my web browser:



Browser



I've searched the API docs and can't find an entry specifying the syntax for this quite basic feature. Anyone know how you do multi-line comments in TypeScript?


More From » angularjs

 Answers
20

/* */ is typescript comment delimiter



They don't work inside a string literal.



You can use HTML comment syntax instead <!-- -->.



@Component({
selector: 'my-app',
template:
`<h1>{{title}}</h1>
<h2>{{lene.name}}</h2>
<div><label>id: </label>{{lene.id}}</div>
<!-- <div>
<label>name: </label>
<input [(ngModel)]=lene.name placeholder=name>
</div> -->'
<div><label>description: </label>{{lene.description}}</div>
})


The HTML commented out this way still is added to the DOM but only as comment.


[#62704] Friday, April 1, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kelleyamiahk

Total Points: 216
Total Questions: 113
Total Answers: 119

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;