Angular6中的[innerhtml]内部未加载角插值绑定值

时间:2018-09-06 08:17:26

标签: angular binding

Component.ts

this.innerHtmlValueData  = "<....>{{title}}<...>"

在HTML

<...[innerHTML]="innerHtmlValueData"></...> 

我也尝试过使用sanitizer.bypassSecurityTrustHtml仍然无法正常工作。它不显示标题值,

1 个答案:

答案 0 :(得分:0)

HTML

<div [innerHTML]="innerHtmlValueData"></div>

在Component.ts

title = "ERP"

innerHtmlValueData  = "<htmltag>"+this.title+"</htmltag>"

innerHtmlValueData:string = `<span class="badge badge-secondary">${this.title}</span>`

尝试