angularjs – ng-html-bind省略样式标记
发布时间:2020-12-17 10:26:36 所属栏目:安全 来源:网络整理
导读:我有这样的ng-bind p ng-bind-html="decodeText(item.description)"/p 使用decodeText $scope.decodeText = function (data) { return data} 但是,以下json丢失了style属性style =“color:#ff0000;”渲染时 [{"title":"I am here","date_received":"Feb 28,
我有这样的ng-bind
<p ng-bind-html="decodeText(item.description)"></p> 使用decodeText $scope.decodeText = function (data) { return data } 但是,以下json丢失了style属性style =“color:#ff0000;”渲染时 [{"title":"I am here","date_received":"Feb 28,2014","description":"<p>EE)u00a0 <span style="color:#ff0000;"> accepted</span></p>n<p>HH)u00a0 <span style="color:#ff0000;">I amnhere; </span><strong>u00a0</strong></p>"} 是什么导致了这个?
ng-bind-html和$sce.trustAsHtml总是一起用于显示平面HTML.
您似乎错过了代码中的$sce部分. 试试这个: $scope.decodeText = function (data) { return $sce.trustAsHtml(data); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |