代码标记在Angular HTML模板中不起作用 [英] Code tag is not working in angular html template

查看:204
本文介绍了代码标记在Angular HTML模板中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的html页面中显示以下代码段.我正在使用角度2.

I would like to display the below snippet in my html page. I'm using angular 2.

{path: 'test', component: TestComponent}

我已在模板中添加以下内容以实现此目的:

I've added below in my template to achieve this:

<pre>
<code>{path: 'test', component: TestComponent}</code>
</pre>

当我加载模板时,看到以下错误.我该如何解决?我不能使用代码标签吗?

When I load the template, I see below error. How do I fix this? Can't I use code tag?

directive_normalizer.js:127 Uncaught Error: Template parse errors:
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.) ("
        </ngb-tab>
    </ngb-tabset>
</div>[ERROR ->]"): TestComponent@31:6
Invalid ICU message. Missing '}'. ("
        </ngb-tab>
    </ngb-tabset>
</div>[ERROR ->]"): TestComponent@31:6

推荐答案

错误消息提供了解决方案.请执行以下操作:

The error Message provides the solution. Do the following:

<pre>
<code>{{"{path: 'test', component: TestComponent}"}}</code>
</pre>

通过插值返回包含内容的字符串.

Through interpolation it returns a string with the content.

这篇关于代码标记在Angular HTML模板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆