问题
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 of
getAllWafers()
'>
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