inspect元素中的输出:
<div ng-bind-html="job.description" class="ng-binding">
"<p><strong>Our Responsibilities</strong></p>"
</div>
这是我的HTML代码:
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.20/angular.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-sanitize/1.3.20/angular-sanitize.min.js"></script>
var myApp = angular.module('rivigoApp', ['ngSanitize']);
<div ng-bind-html="job.description"></div>
如何让它在输出中编译HTML?我认为主要问题是引号“”但我无法弄清楚如何继续。我尝试过使用其他各种方法。
答案 0 :(得分:1)
在您的控制器中注入$ sce服务并使用它,如下所示
app.controller('mainCtrl',function($sce , $scope){
$scope.job = {
description : $sce.trustAsHtml("<p><strong>Our Responsibilities</strong></p>")
};
})
$sce
Reference