我正在尝试将 HTML 字符串绑定(bind)到 Angular 2 工具提示中。但它呈现为 HTML,显示为纯字符串。有什么方法可以将字符串呈现为 HTML。
这是我的代码:
在 View 中:
<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;}
提前致谢。
最佳答案
对我们来说是个坏消息: Angular Material 工具提示不支持 HTML,目前,他们无意支持它。 Here更多信息。
关于javascript - 带有 HTML 内容的 Angular 2 Material 工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44177787/