【发布时间】:2019-12-09 16:56:45
【问题描述】:
我需要使用 Angular 7 在 HTML 模板中实现动态变量编译。
这是我的示例代码:
app.component.ts:
username = 'User Name';
sampleData = "This is my <strong>{{username}}</strong>";
app.component.html:
<div [innerHtml]="sampleData"></div>
但是,输出仍然是
This is my {{username}}.
我的预期输出是,
This is my UserName
使用$compile 可以在Angular 1 中实现相同的功能。请让我知道如何在 Angular 7 中实现这一目标
【问题讨论】:
-
这个答案可能会有所帮助stackoverflow.com/questions/34784778/…
标签: javascript html css json angular