我们正在使用 AngularJS 尝试将用户输入的内容显示为 HTML。大多数情况下,用户输入我们使用 ng-bind-html 正确显示的有效/安全数据。有时他们会输入无效的 HTML,我仍希望将其显示为原始文本。
如果我使用 ng-bind-html 尝试显示无效的 HTML,我会收到此错误:
[$sanitize:badparse] The sanitizer was unable to parse the following block of html:
我不想使用 trustAsHtml,因为我不信任我们的消毒剂,并希望确保我们不会在页面上显示不安全的 html。