AngularJS - ng-bind-html无法使用

时间:2015-09-03 06:53:07

标签: angularjs ng-bind-html

我从数据库获取HTML数据,数据类似于 -

var feature = new ol.Feature({
    geometry: new ol.geom.Polygon(coordinates)
});

var vectorLayer = new ol.layer.Vector({
    source: new ol.source.Vector({
        features: [ feature ]
    })
});

map.add(vectorLayer);

我正在使用"<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> 来呈现此HTML,但它不会呈现整个HTML。它只是渲染

<div ng-bind-html="connection.LikeCountMessage"></div>

我期待像

这样的东西
<div ng-bind-html="connection.LikeCountMessage" class="ng-binding">
<span class="ui-like "></span>
</div>

我该如何解决这个问题?我错过了什么?

1 个答案:

答案 0 :(得分:0)

使用ng-bind-html-unsafe代替ng-bind-html