Angular 2 srcdoc polyfill不起作用

Ser*_*nho 8 polyfills microsoft-edge angular

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

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

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

我用它像:

 <iframe class="ticket-frame" [srcdoc]="ticket.html | htmlSafe"
                  tlIframeAutoHeight>
 </iframe>
Run Code Online (Sandbox Code Playgroud)

如果你问我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'
      );
    });
  }
}
Run Code Online (Sandbox Code Playgroud)

Microsoft Edge 35忽略了srcdoc属性,任何有关问题的想法是什么?

我也接受变通办法.

kem*_*sky 5

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

<iframe #frame></iframe>

import * as srcDoc from 'srcdoc-polyfill';

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

srcDoc.set(this.iframe.nativeElement, "<html><body>test</body></html>");
Run Code Online (Sandbox Code Playgroud)