Angular 4 iframe无法在iframe中隐藏元素

时间:2018-08-03 09:40:01

标签: angular iframe

我想隐藏iframe内的特定元素。我尝试了ElementRef。但是当我使用getElementsByClassName('example-class')时,它返回空。这是我的代码

this.iframe.nativeElement.onload = function() {
const els = self.iframe.nativeElement.contentDocument.getElementsByClassName('hidden-xs');
if (els.length > 0) {
    els[0].style.display = 'none';
}

};

我还尝试了iframe onload,ngoninit和ngafterviewinit。

0 个答案:

没有答案
相关问题