适用于角度 < 1.2 的版本
http://jsfiddle.net/AQWAR/
的HTML
<div ng-app="myapp">
<form>
<input type="text" ng-model="ddata"/>
</form>
{{ddata}}
<div ng-bind-html-unsafe='ddata'>
</div>
</div>
JS
angular.module("myapp", []);
适用于 Angular > 1.2 的版本(专门使用 1.2.1 测试)
http://jsfiddle.net/AQWAR/1/
HTML
<div ng-app="myapp" ng-controller="MyCtrl">
<form>
<input type="text" ng-model="ddata.someString"/>
</form>
{{ddata}}
<div ng-bind-html='ddata.trustedVersion'>
</div>
</div>
JS
angular.module("myapp", []).controller("MyCtrl", ["$scope","$sce", function($scope, $sce){
$scope.ddata = {someString:"", trustedVersion:""}
$scope.$watch("ddata.someString", function(newVal){
$scope.ddata.trustedVersion = $sce.trustAsHtml(newVal);
},true);
}]);
对于一些更安全的选择,请查看 $sanitize 和 $sce
http://docs.angularjs.org/api/ngSanitize.$sanitize
http://docs.angularjs.org/api/ng.$sce