gpt4 book ai didi

javascript - Angularjs ng-bind-html-unsafe 替换

转载 作者:可可西里 更新时间:2023-11-01 02:49:25 25 4
gpt4 key购买 nike

我曾经能够使用 ng-bind-html-unsafe 来输出未净化的代码(因为净化发生在服务器端)。

但是现在那个选项不见了?我知道我可以使用 $sce.trustAsHtml,但是在 unsafe 如此易于使用的情况下,将其添加到 JavaScript 中是一个巨大的痛苦。

我如何获得不安全的返回值?

最佳答案

又简单了。

App.filter('unsafe', ['$sce', function ($sce) {
return function (val) {
return $sce.trustAsHtml(val);
};
}]);

用法:

<any ng-bind-html="content | unsafe"></any>

有关 html 绑定(bind)的更多信息,请查看文档 here.

只是一个警告:确保您确实信任 html,否则您可能会在您的网站安全性中打开一个漏洞。

关于javascript - Angularjs ng-bind-html-unsafe 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18926306/

25 4 0
文章推荐: java - 终结者守护者
文章推荐: c++ - tcp通信的线程
文章推荐: .NET TCPClient 连接状态
文章推荐: java - 测试 Swing 应用
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com