我有包含HTML的JSON變量。AngularJS使用雙括號表示法呈現HTML
通過這樣做:{{source.HTML}}
Angular顯示<
和>
而不是<
和>
。
我該怎麼做Angular呈現實際的HTML?
UPDATE:
這是我的控制器:
app.controller('objectCtrl', ['$scope', '$http', '$routeParams',
function($scope, $http, $routeParams) {
var productId = ($routeParams.productId || "");
$http.get(templateSource+'/object?i='+productId)
.then(function(result) {
$scope.elsevierObject = {};
angular.extend($scope,result.data[0]);
});
}]);
在我的HTML然後我就可以使用:
<div>{{foo.bar.theHTML}}</div>
可能重複[如何擁有AngularJS輸出轉義HTML(http://stackoverflow.com/questions/20436579/how-to-have-angularjs-output-escaped-html) – Seth 2015-02-11 01:00:13
看看['ng-bind-html'](https://docs.angularjs.org/api/ng/directive/ngBindHtml) – 2015-02-11 01:04:33
Hi @Seth它不是重複的,這個重點放在花括號上。 – 2015-02-11 01:08:51