如何将HTML插入ng-repeat?

时间:2014-08-13 16:56:55

标签: angularjs

自angular1.2起停止工作 (text.text是HTML)

<div ng-repeat="text in texts" ng-bind-html-unsafe="text.text">{{text.text}}</div>

知道如何让它恢复正常吗?

1 个答案:

答案 0 :(得分:0)

如果您使用的是角度1.2

,请使用ng-bind-html和$sce服务
angular.module("app").controller("myCtrl", ["$scope", "$sce", function ($scope, $sce) { 
     $scope.htmlString = $sce.trustAsHtml("<h1>HTML</h1>");
}]);

<span ng-bind-html="htmlString"></span>

<强> DEMO