标签:
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会把标签的属性都移除,以及绑定在元素上的事件.仅保留了标签和内容
标签:
原文地址:http://www.cnblogs.com/toward-the-sun/p/4288306.html