0
我已經查找了如何在angularJS中呈現html標記的類似問題,但是他們都沒有爲我工作,因爲我正在使用ng-repeat。任何人都有任何建議。從AngularJS對象中呈現html標記
<div ng-repeat="o in SurveyResults.SurveyQuestions">
{{o.SurveyQuestionId}}
{{o.QuestionText}}
</div>
我o.QuestionText
有數據如<b>How well do we deliver on our promises?</b> <br />Consider our responsiveness to your requests, ability to meet deadlines and <i>accountability for the outcomes</i>.
它顯示的標籤,而無需渲染的標籤。
我曾嘗試把這個在我的JS文件
homePage.directive('htmlSafe', function($parse, $sce) {
return {
link: function(scope, elem, attr) {
var html = attr.ngBindHtml;
if(angular.isDefined(html)) {
var getter = $parse(html);
var setter = getter.assign;
setter(scope, $sce.trustAsHtml(getter(scope)));
}
}
};
});
然後設置HTML綁定在重複這樣
<div ng-repeat-html="o in SurveyResults.SurveyQuestions">
{{o.SurveyQuestionId}}
{{o.QuestionText}}
</div>
任何其他意見?