[英]Display HTML tags a string in inner html tag
I want to display html tags in string format in inner html tag我想在内部 html 标签中以字符串格式显示 html 标签
I have following string我有以下字符串
myString = "<span class="display-red"><a href="link"><span>ABC <a href=""></a>PQR</span><span>abc@gmail.com</span></a></span>"
This is my html tag in code (Here I want to render this html tag)这是我在代码中的 html 标签(这里我想渲染这个 html 标签)
<span [innerHtml]="myString"></span>
Expected Output预计 Output
ABC <a href=""></a>PQR
abc@gmail.com
I want to display some html tag as it is in my output.我想显示一些 html 标签,因为它在我的 output 中。
In the html you want to display, replace <
with <
在你要显示的html中,将
<
替换为<
(or >
with >
) (或
>
与>
)
myString = "<span class="display-red"><a href="link"><span>ABC <a href=""></a>PQR</span><span>abc@gmail.com</span></a></span>"
Use <
使用
<
instead of <
and >
而不是
<
和>
instead of >
.而不是
>
。 You will get exactly what you want.你会得到你想要的。
Solution:解决方案:
myString = "<span class="display-red"><a href="link"><span>ABC <a href=""></a>PQR</span><span>abc@gmail.com</span></a></span>"
You should replace the <
with <
您应该将
<
替换为<
and the >
with >
和
>
与>
. . This will display it as regular text.
这会将其显示为常规文本。
You should replace the <
with < and the >
with >您应该将
<
替换为 < 并将>
替换为 >
myString = "<span class="display-red">ABC <a href="link"><span><a href=""></a></a>PQR</span><br><span>abc@gmail.com</span></span>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.