$sanitize和$sce服务的使用方法
var app =angular.module(‘myApp‘,[‘ngSanitize‘]);
app.controller(‘ctrl‘,function($scope,$sce){
$scope.myHtml = ‘<p >an html\n‘ +
‘<em onclick="this.textContent=\‘code_bunny\‘">click here</em>\n‘ +
‘snippet</p>‘;
$scope.trustHtml = $sce.trustAsHtml($scope.myHtml)
}
$sanitize会把标签的属性都移除,以及绑定在元素上的事件.仅保留了标签和内容

浙公网安备 33010602011771号