zoukankan      html  css  js  c++  java
  • angular ng-bind-html 对src路径失效 解决方案

    json内容

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

    用ng-bind-html绑定json数据,浏览器将会输出
    <img width="600" alt="">
    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/')//第二步
    就酱紫,有空再排版


  • 相关阅读:
    c++之五谷杂粮4---explicit
    ping
    Swift常量和变量
    Swift数据类型简介
    Swift 注释
    Swift标示符以及关键字
    xcode简介
    认识Swift
    Android_adb详解
    详解Android AM命令
  • 原文地址:https://www.cnblogs.com/light-j/p/4651369.html
Copyright © 2011-2022 走看看