我有以下Angular2 TypeScript代码,其中一节按照Javascript约定注释掉:
@Component({ selector: 'my-app', template: `{{title}}
{{lene.name}}
{{lene.id}}/**/`{{lene.description}}})
但是,一旦TypeScript编译为Javascript,我将以下输出到我的Web浏览器:
我搜索过API文档,但找不到指定此基本功能语法的条目.有人知道你如何在TypeScript中进行多行注释吗?
/* */
是打字稿评论分隔符
它们不能在字符串文字中起作用.
您可以使用HTML注释语法.
@Component({ selector: 'my-app', template: `{{title}}
{{lene.name}}
{{lene.id}}'{{lene.description}}})
以这种方式注释掉的HTML仍然被添加到DOM中,但仅作为注释添加.