示例
下例演示了将<p>元素的innerHTML绑定到变量myText:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>欢迎来到蝴蝶教程</title>
<script src="//cdn.bootcss.com/angular.js/1.5.8/angular.min.js"></script>
<script src="https://cdn.staticfile.org/angular.js/1.5.8/angular-sanitize.js"></script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p ng-bind-html="myText"></p>
</div>
<script>
var app = angular.module("myApp", ['ngSanitize']);
app.controller("myCtrl", function($scope) {
$scope.myText = "我的名字是: <h1>中国</h1>";
});
</script>
</body>
</html>
尝试一下