Javascript 如何从SafeHtml对象中获取经过消毒的值(html字符串)?

Javascript 如何从SafeHtml对象中获取经过消毒的值(html字符串)?,javascript,angular,Javascript,Angular,我正在使用DomSanitizer函数bypassSecurityTrustHtml()进行清理。该值存储在更改此BreaksApplicationSecurity属性的中。这可能足以说明不用它 const safeHtml = this.domSanitizer.bypassSecurityTrustHtml('<div>hello</div>'); const html = safeHtml['changingThisBreaksApplicationSecurity

我正在使用DomSanitizer函数bypassSecurityTrustHtml()进行清理。

该值存储在更改此BreaksApplicationSecurity属性的
中。这可能足以说明不用它

const safeHtml = this.domSanitizer.bypassSecurityTrustHtml('<div>hello</div>');
const html = safeHtml['changingThisBreaksApplicationSecurity'];
// html === <div>hello</div>;
const safeHtml=this.domsanizer.bypassSecurityTrustHtml('hello');
const html=safeHtml['changingThisBreaksApplicationSecurity'];
//html==你好;
但是,您应该只使用消毒剂和模板中返回的值:

<div [innerHTML]="safeHtml"></div>


现在,div将把html的内容传递到
bypassSecurityTrustHtml

我们如何在没有代码的情况下帮助您?到目前为止,您尝试了什么?Tnx,我认为一定有更简单的方法来获取值:)我将该值发送到api,以便它可以保存在db中。