gpt4 book ai didi

angularjs - 有没有一种简单的方法可以将我的模型中的原始 HTML 包含到带有 AngularJS 的页面中?

转载 作者:行者123 更新时间:2023-12-04 04:45:47 26 4
gpt4 key购买 nike

我的 model.question.text 中有原始 HTML 我正在查看以下内容:

app.directive('ngHtml', function() {
return function(scope, element, attrs) {
scope.$watch(attrs.ngHtml, function(value) {
element[0].innerHTML = value;
});
}
});

有人可以告诉我是否有一种简单的方法可以将其包含在我的页面中。

最佳答案

我认为您正在寻找 ngBindHtmlUnsafe :

Creates a binding that will innerHTML the result of evaluating the expression into the current element. The innerHTML-ed content will not be sanitized! You should use this directive only if ngBindHtml directive is too restrictive and when you absolutely trust the source of the content you are binding to.

See $sanitize docs for examples.

关于angularjs - 有没有一种简单的方法可以将我的模型中的原始 HTML 包含到带有 AngularJS 的页面中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18206039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com