首页 > 解决方案 > 有没有办法将html类和目标链接文本转换为普通链接文本

问题描述

我正在使用 innerhtml 在我的应用程序中绑定聊天消息。从服务器端我发送了一条消息,我正在尝试将 html 内容转换为角度 6 中的普通链接内容。

<a href="https://helloworld.com/test&quot;" class="linkified" target="_blank">https://helloworld.com/test"</a>

在客户端我得到的输出为

https://helloworld.com/test" class="linkified" target="_blank">https://helloworld.com/test" class="linkified" target="_blank">" class="linkified" target="_blank">https://helloworld.com/test" class="linkified" target="_blank">https://helloworld.com/test

如何在我的聊天窗口中显示正常的超链接。我的输出应该是https://helloworld.com/test "

我的聊天窗口设计为

<p [innerHTML]="msgObj.message" class="mr-2 pr-1 mb-0"></p>

在我们的应用程序中收到消息时。在 api 中显示为

{"message": "<a href="<a href="https://helloworld.com/test&quot" class="linkified" target="_blank">https://helloworld.com/test&amp;quot</a>;" class="linkified" target="_blank"><a href="https://helloworld.com/test&quot;</a>" class="linkified" target="_blank">https://helloworld.com/test"</a></a>"}

标签: htmlcssangular6chatmessage

解决方案


推荐阅读