Parent listeners triggering Angular 2 iframe re-render

做~自己de王妃 提交于 2020-01-06 02:12:45

问题


EDIT:

Looks like ANY event is causing angular to re-render the component(ancestor listeners and siblings)...is this a design intent behind ngZone and component interaction?


original:

I have a web page with an iframe running an Angular deployment. The page (parent to the iframe running angular) looks like it has a blanket click event. I can't seem to find a way to prevent this listener from causing NgZone from triggering angular's ng directives from being evaluated every time the parent event triggers...

pageLoad -> 
iframeLoad -> 
routing within angular works fine -> 
component renders -> 
clickEvent (within component DOM elements) causes subscribed/observables to re-evaluate.

As for the angular code:

I am pulling from service private developmentService: RestService

onInit() subscribes to a service call .subscribe(response => this.developmentWafers = response);

I then use a loop <ng-container *ngFor='let wafer ofgetAllWafers()'> where getAllWafers() returns the subscribed result this.developmentWafers


getAllWafers(){
        return this.developmentWafers;
    }

runs ~ 3 times per each listener when iframe parent window gets click event


What I've tried prior to arriving to conclusion that issue is from iframe parent:

e.stopPropagation e.preventDefault I've tried from ngZone perspective by building custom zoning component and changed all events within iframe to be scoped within their own NameSpace

来源:https://stackoverflow.com/questions/54527055/parent-listeners-triggering-angular-2-iframe-re-render

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!