我正在尝试将 HTML 字符串绑定到 Angular 2 工具提示中。但它呈现为 HTML,显示为纯字符串。有什么办法可以将字符串呈现为 HTML。
这是我的代码:
在视图中:
<span class="icon-status" mdTooltip="{{value.status}}"></span>
零件:
value.status = this.sanitizer.bypassSecurityTrustHtml(this.getStatusTemplate(value.status));
getStatusTemplate(status: IIconStatus): string{
let HTML =`
<div>Event Title</div>
<div class="">
<table>
<thead>
<th>User</th>
<th>User</th>
<th>User</th>
<th>User</th>
</thead>
</table>
</div>
`;
return HTML;}
提前致谢。
原文由 Kesavan R 发布,翻译遵循 CC BY-SA 4.0 许可协议
对我们来说是个坏消息:角度材料工具提示不支持 HTML,目前,他们无意支持它。 这里 有更多信息。