I'm submitting a...
Current behavior
@HostListener runs function in whatever zone it was in during creation
Expected behavior
@HostListener should allow an optional zone to be specified or a Boolean parameter to always run in NgZone
Alternately, provide zone creation context for component creators such as NgForOf. This may be easier to implement and more general purpose.
Minimal reproduction of the problem with instructions
Create component with a @HostListener event outside of NgZone. Every time that event is fired, it will be run in the zone it was created in.
What is the motivation / use case for changing the behavior?
Creating a virtual scroller and during creation of virtual components, the component's @HostListener's will register in the zone it was created in (not ngZone). It looks very ugly to have all events wrapped in zone.run functions. It would be nice to have a way to bind the function call to a particular zone declaratively.
I'm submitting a...
Current behavior
@HostListenerruns function in whatever zone it was in during creationExpected behavior
@HostListenershould allow an optional zone to be specified or a Boolean parameter to always run inNgZoneAlternately, provide zone creation context for component creators such as
NgForOf. This may be easier to implement and more general purpose.Minimal reproduction of the problem with instructions
Create component with a
@HostListenerevent outside ofNgZone. Every time that event is fired, it will be run in the zone it was created in.What is the motivation / use case for changing the behavior?
Creating a virtual scroller and during creation of virtual components, the component's
@HostListener's will register in the zone it was created in (not ngZone). It looks very ugly to have all events wrapped inzone.runfunctions. It would be nice to have a way to bind the function call to a particular zone declaratively.