[英]Allow html in an <a> tag title attribute
I have tried to find a solution to this problem and so far I have come up with this pipe that should allow HTML 我试图找到解决此问题的方法,到目前为止,我已经提出了应该允许HTML的管道
import { PipeTransform, Pipe } from "@angular/core";
@Pipe({
name: "toHtml"
})
export class ToHtmlPipe implements PipeTransform {
transform(content) {
return `<b>${content}</b>`;
}
}
I have a link, which displays a data tool tip on hover: 我有一个链接,该链接在悬停时显示数据工具提示:
<a *ngIf="day.Info.Info" data-toggle="tooltip" [title]="day.Info.Info | toHtml" placement="right"><i style="color:black" class="glyphicon glyphicon-comment"></i></a>
However, this is the result I get: 但是,这是我得到的结果:
So the pipe isn't working and afaik I can't use [innerHtml]=""
since it just changes the link to the string, not the icon. 因此,管道无法正常工作,并且afaik我无法使用
[innerHtml]=""
因为它只是更改了字符串的链接,而不是图标的链接。
Thanks in advance for your help 在此先感谢您的帮助
As per the comments, looking at the Bootstrap documentation for Tooltips; 根据评论,查看Bootstrap文档中的工具提示;
https://v4-alpha.getbootstrap.com/components/tooltips/#interactive-demo https://v4-alpha.getbootstrap.com/components/tooltips/#interactive-demo
And with custom HTML added:
并添加了自定义HTML:
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>"> Tooltip with HTML </button>
You require the data-html="true"
attribute to be placed on the <a>
element. 您需要将
data-html="true"
属性放置在<a>
元素上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.