Javascript 警告:正在清理某些内容,请参阅http://g.co/ng/security#xss
在我的角度样本中有这样的警告 警告:正在清理某些内容,请参阅 闪电战: 有人请帮我离开这里 提前谢谢 我已经尝试过这个解决方案 仍然会出现警告Javascript 警告:正在清理某些内容,请参阅http://g.co/ng/security#xss,javascript,angular,angular2-template,Javascript,Angular,Angular2 Template,在我的角度样本中有这样的警告 警告:正在清理某些内容,请参阅 闪电战: 有人请帮我离开这里 提前谢谢 我已经尝试过这个解决方案 仍然会出现警告 getCellContent(e): string { if (e && e.targetCell.className.indexOf('e-valuescontent') > -1 ) { template = '<input type="checkbox">'; //Here, you
getCellContent(e): string {
if (e && e.targetCell.className.indexOf('e-valuescontent') > -1 ) {
template = '<input type="checkbox">'; //Here, you can append the html elements
}
else {
template = '';
}
return this.sanitizer.sanitize(SecurityContext.HTML, template) || '';
}
getCellContent(e):字符串{
if(e&&e.targetCell.className.indexOf('e-valuescontent')>-1){
template='';//在这里,您可以附加html元素
}
否则{
模板=“”;
}
返回此.sanitizer.sanitize(SecurityContext.HTML,模板)| |“”;
}
警告:正在清理某些内容,请参见您尝试过吗
return this.sanitizer.bypassSecurityTrustHtml(template);
而不是
return this.sanitizer.sanitize(SecurityContext.HTML, template) || '';
Angular需要信任通过innerHTML插入的html。此绕过securitytrusthtml(模板)
方法将有所帮助。这对我有用。让我知道你的