【发布时间】:2015-09-03 06:53:07
【问题描述】:
我正在从数据库中获取 HTML 数据,数据类似于 --
"<span class=\"ui-like \" data-tipcontent=\"initialmessage\" data-contentid=\"4f3f9827-364a-41b8-adf4-a5c4ada64b8d\" data-contenttypeid=\"f7d226ab-d59f-475c-9d22-4a79e3f0ec07\" data-initialcount=\"5\" data-initialstate=\"true\" data-readonly=\"false\" data-initialmessage=\"You and <span class="who-likes">4 others</span> like this\" data-format=\"{message}\" data-configuration=\"Format=%7Bmessage%7D\"></span>
我正在使用<div ng-bind-html="connection.LikeCountMessage"></div> 来呈现这个 html,但它没有呈现整个 HTML。它只是渲染
<div ng-bind-html="connection.LikeCountMessage" class="ng-binding">
<span class="ui-like "></span>
</div>
我期待类似的东西
<div ng-bind-html="connection.LikeCountMessage" class="ng-binding">
<span class="ui-like ">You and 4 other like this</span>
</div>
我该如何解决这个问题?我错过了什么?
【问题讨论】:
-
您发布的字符串不是有效字符串。它包含的 HTML 在另一个 span 的属性内有一个 span。不知道你为什么期待你所期望的。