关闭Angularjs对HTML标签自动转义
来源:互联网 发布:淘宝美工速成教程 编辑:程序博客网 时间:2024/05/16 13:02
当Angular绑定的字符串中含有HTML标签的时候,其中碰到 AngularJS 获取的是一段 HTML 文本,如果直接使用 data-ng-bind 的话是被转义过的,使用 data-ng-bind-html 则可以取消转义。但是直接使用 data-ng-bind-html 的话会提示错误。
Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context.
HTML 片段需要先使用 $sce.trustAsHtml(html_in_string) 将标记为信任,然后才可以使用 data-ng-bind-html="html_in_string" 取消转义。
angular.module('myApp',[]) .controller('orderDetailController',function($scope,$http,$location,$timeout,$sce){ AngularAction($scope,$http,$location,$timeout,$sce); });function AngularAction($scope,$http,$location,$timeout,$sce){$scope.comment = $sce.trustAsHtml($scope.pricelist.comment);}HTML代码如下
<p style="line-height:2;display: inline"> <span data-ng-bind-html ="comment"></span> </p>
阅读全文
0 0
- 关闭Angularjs对HTML标签自动转义
- 关于angularJS自动转义html标签
- 关于angularJS绑定数据时自动转义html标签
- 关于angularJS绑定数据时自动转义html标签
- 关于angularJS绑定数据时自动转义html标签
- Angularjs绑定数据时对html标签的转义
- AngularJS取消对HTML转义
- django标签自动转义的关闭
- angularJS绑定数据中对标签转义的处理
- Django模板中的关闭和开启HTML自动转义,解析
- Django模板中的关闭和开启HTML自动转义,解析
- angularjs ng-bind-html 指令 对html标签转译
- 使用标签对HTML特殊字符进行转义
- html标签转义表
- java转义HTML标签
- HTML标签转义问题
- js转义html标签
- 转义HTML标签
- Gradle多项目构建并将项目导入到Eclipse
- windows server2008 创建新用户 远程桌面连接 和 多用户登录问题
- 华为手机调试没有LOG解决方案
- 联合体(union)的使用方法及其本质
- Linux下MySQL5.7.18二进制包安装(无默认配置文件my_default.cnf)
- 关闭Angularjs对HTML标签自动转义
- bzoj1679
- Java菜鸟面试突破系列Java集合源码解读系列:HashMap实现原理
- cocoa pods的安装与我遇到的问题
- JS内置对象、函数内置对象、宿主对象
- Access denied for user 'root'@'localhost' (using password: YES)
- Json字符串转函数代码
- C++接口,纯虚函数,抽象类的关系
- 游戏蜂窝研究--全局的异常捕获器