将加载事件侦听器添加到对象元素时的加载循环

时间:2019-08-05 02:03:14

标签: typescript angular8

当我添加一个函数来监听对象元素中的数据加载时,这将进入加载无限循环

这只会在Angular 8中发生,然后才在Angular 4、6 y 7中使用相同的代码并正常工作

component.template.html

...
 <object #object [data]="_data" (load)="onObjectLoaded()"></object>
...

component.component.ts

 @ViewChild('object', { static: true }) object: ElementRef<HTMLObjectElement>;
...
   onObjectLoaded() {
    this.svg = 
     this.object.nativeElement.contentDocument.querySelector('svg');
    this.onLoadObject.emit(true);
  }
...

0 个答案:

没有答案