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>
任何其他意见?