
同时使用ngsanitize。它只显示未应用css的html。
例如:上面的图像应该是输出,但使用ngsanitize时,它只显示文本
使用ngsanitize可以添加什么来显示具有适当css的元素。
<p ng-bind-html ="the text to be displayed(test video)"></p>发布于 2019-06-04 15:45:01
如果我没理解错你的问题,fiddle
你可以使用$sce.trustAsHtml(),直接在html字符串中使用内联样式,你可以这样做,控制器:
$scope.trustAsHtml = function(string) {
return $sce.trustAsHtml(string);
};和HTML格式
<div data-ng-bind-html="trustAsHtml(htmlString)"></div>发布于 2019-06-04 15:47:51
请尝试使用$sce。在将其绑定到用于ng-bind-html的作用域变量之前。下面是一个例子
<p ng-bind-html ="styledHTML"></p>在你的控制器中
$scope.styledHTML = $sce.trustAsHtml('<span style="background-color: cyan;">test video</span>');https://stackoverflow.com/questions/56437864
复制相似问题