方法1:写filter

<div ng-bind-html="showContent | html" class="detail-content">

deliciousApp.filter('html', ['$sce', function ($sce) {
return function (text) {
return $sce.trustAsHtml(text);
};
}]);

方法2:

<div ng-controller="ExampleController">
<p ng-bind-html="myHTML"></p>
</div> angular.module('bindHtmlExample', ['ngSanitize'])
.controller('ExampleController', ['$scope', function($scope) {
$scope.myHTML =
'I am an <code>HTML</code>string with ' +
'<a href="#">links!</a> and other <em>stuff</em>';
}]);
 
05-01 03:59