码迷,mamicode.com
首页 > Web开发 > 详细

angular ng-bind-html 对src路径失效 解决方案

时间:2015-07-16 16:17:54      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

json内容

;<img src="/newsfile/1506271512489.jpg" width="600" height="450" alt="" /></p><p style="text-align: center;">

用ng-bind-html绑定json数据,浏览器将会输出
<img width="600" >
ng自动过滤了src属性,再次琢磨发现src是全路径的时候,浏览器就能输出我想要的src了
猜测angularjs是处于安全考虑,那就手动加全路径吧
html=htmldecode(dt.cContent)//第一步还是反编译
sr=src="/;
sh="height"
$scope.list.cContent=htmldecode(dt.cContent).replace(new RegExp(sh,g),k).replace(new RegExp(sr,g),src="http://www.xjj.com/)//第二步

 

就酱紫,有空再排版


angular ng-bind-html 对src路径失效 解决方案

标签:

原文地址:http://www.cnblogs.com/light-j/p/4651369.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!