Iframe 在 kolkov angular 编辑器中不起作用

Iframe doesn't work in kolkov angular editor

Kolkov angular 编辑器不支持 Iframe。

套餐:https://www.npmjs.com/package/@kolkov/angular-editor

在编辑器中,它看起来工作正常,但前面板没有显示任何内容

预期结果是

为此,您需要在 angular 编辑器配置中进行更改: 您需要设置 sanitize: false.

config: AngularEditorConfig = {
    sanitize: false,
  .........................
  };

由于senetize:false chrome给你这样的前端错误:

WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).

您可以通过创建用于清理的自定义管道来修复此错误 HTML :

消毒-html.pipe.ts

import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';

@Pipe({
  name: 'sanitizeHtml'
})
export class SanitizeHtmlPipe implements PipeTransform {

  constructor(private _sanitizer: DomSanitizer) {
  }

  transform(v: string): SafeHtml {
    return this._sanitizer.bypassSecurityTrustHtml(v);
  }
}

在HTML

<p *ngIf="appMessageData" [innerHTML]="appMessage | sanitizeHtml"></p>

这对你有帮助:)