angularJs中$sce服务安全显示html文本
来源:互联网 发布:什么牌子的网络电视好 编辑:程序博客网 时间:2024/06/01 10:05
<div ng-app="module" ng-controller="ctrl"> {{data}} <hr> <div ng-bind-html="data"></div> <hr> <div ng-bind-html="title | trustHtml"></div></div><script> var m = angular.module('module', []); /*$sce服务写成过滤器*/ m.filter('trustHtml',['$sce',function($sce){ return function(data){ return $sce.trustAsHtml(data); } }]) m.controller('ctrl', ['$scope', '$sce', function ($scope, $sce) { /*第一种:不用过滤器的方式*/ $scope.data = $sce.trustAsHtml('<h1 style="color:red;">angularJs</h1>'); /*第二种:使用过滤器的方式*/ $scope.title = '<h3 style="color:red;">angularJs</h3>'; }]);</script>
阅读全文
0 0
- angularJs中$sce服务安全显示html文本
- 【AngularJs】---$sce 输出Html
- angularJs 中的ng-bind-html指令和$sce服务
- angularjs显示html文本
- angularjs $sce
- angularJS 显示带html的文本
- $sce服务----- 将请求到的html代码 引入到项目中
- AngularJS常用服务($http、$location、$sce等)
- AngularJS-$sce的使用
- angular中的ng-bind-html指令和$sce服务
- angular中的ng-bind-html指令和$sce服务
- angular中的ng-bind-html指令和$sce服务
- angular中的ng-bind-html指令和$sce服务
- 用ng-bind-html指令和 $sce服务 实现页面输出html
- Android中Textview显示带html文本
- Android中Textview显示带html文本
- iOS中TextView显示HTML文本
- Angularjs动态绑定HTML文本
- 图形分析之Nsight的使用
- 棘修CADfix 7.1+Grapyuoft Crchicbd 2017
- 协程resume()传入的参数
- 20170611 用JS while循环实现斐波那契数列求兔子总数
- 第8章 不相交集类
- angularJs中$sce服务安全显示html文本
- C++析构函数为什么要为虚函数
- 01背包
- android bootanimation的启动与退出
- js中的if用法
- hdu 2492 Ping pong
- 减少git上传代码的冲突
- js中的 switch判断用法
- swing 飞机大战 三 自己飞机的移动和发射子弹