【发布时间】:2018-03-13 21:15:02
【问题描述】:
使用 Angular 5 和 Firebase,我创建了一个评论网站,允许用户在 CreateComponent 上创建评论并在 ReviewComponent 上阅读它们。我希望评论的正文能够包含链接或图像的 HTML。
ReviewComponent 提取评论正文:
<p style="margin-bottom: 2rem; white-space: pre-wrap;">{{review.body}}</p>
我正在使用pre-wrap 来维护正文的换行符。
CreateComponent 的示例输入是:
I already can’t wait to see <a href="http://www.ign.com/articles/2017/11/30/marvels-the-avengers-infinity-war-trailer-breakdown"> what comes next.</a>
当我检查身体的输出时,我看到了这个:
<p _ngcontent-c1 style="margin-bottom: 2rem; white-space: pre-wrap;">I already can’t wait to see &lt;a href="http://www.ign.com/articles/2017/11/30/marvels-the-avengers-infinity-war-trailer-breakdown"&gt;what comes next.&lt;/a&gt;</p>.
如何更改 HTML 以使字符串能够正确处理链接和图像?
【问题讨论】:
-
我认为您需要使用富文本编辑器。