【发布时间】:2015-12-11 11:58:31
【问题描述】:
我已经完成了这里提到的所有事情on post about same topic 。即我使用'ngSanitize'并使用'sce.trustAsHtml()'格式化html内容,如果html有文本和图像,它会正确呈现,但是当html内容有使用'css'加载的图像时它不会正确呈现图像。这是我要绑定的 HTML 内容。
<html> <head> <style> body{ padding: 0 0; margin: 0 0; } .img-wrapper{
width: 100%; height: 50%; margin: 0 auto; background: url('http://www.fnordware.com/superpng/pnggrad8rgb.png')
no-repeat center; -webkit-background-size: contain; -moz-background-size: contain;
-o-background-size: contain; background-size: contain; } </style> </head> <body> <div>
<div class='img-wrapper'></div><div style='font-size: 20px;' >Test the image upload or not
successfully</div> <div align=center style='font-size: 17px;'>Address goes here</div>
</div> </body></html>
我的js代码如下:
$scope.content = $sce.trustAsHtml(adTemp.content);
将其绑定的 Html 代码如下:
<div ng-bind-html="content"> </div>
【问题讨论】:
标签: javascript css angularjs ng-bind-html