Angular 2 srcdoc polyfill 不工作

Angular 2 srcdoc polyfill doesn't work

我正在使用 Angular 2 和 angular-cli,我想添加 srcdoc polyfill 以支持 Microsoft Edge。所以:

我添加到package.jsonhttps://github.com/jugglinmike/srcdoc-polyfill

我在 polyfills.ts 中导入了 import 'srcdoc-polyfill/srcdoc-polyfill.min';

我是这样用的:

 <iframe class="ticket-frame" [srcdoc]="ticket.html | htmlSafe"
                  tlIframeAutoHeight>
 </iframe>

碰巧,如果你向我询问 IframeAutoHeight 指令,这里是代码:

@Directive({

  selector: '[tlIframeAutoHeight]'
})
export class IframeAutoHeightDirective {

  constructor(element: ElementRef, renderer: Renderer) {
    renderer.listen(element.nativeElement, 'load', () => {
      renderer.setElementStyle(
        element.nativeElement,
        'height',
        element.nativeElement.contentWindow.document.body.clientHeight + 'px'
      );
    });
  }
}

Microsoft Edge 35 忽略了 srcdoc 属性,有什么问题吗?

我也接受解决方法。

由于某些原因属性不起作用:

<iframe #frame></iframe>

import * as srcDoc from 'srcdoc-polyfill';

@ViewChild('frame')
public iframe:ElementRef;

srcDoc.set(this.iframe.nativeElement, "<html><body>test</body></html>");