0

I understand that when Angular finds this code in a component

    @HostListener('window:keyup')
    handler(event) { ... }

it attaches handler to the global event listener and every time a keyup event is fired it invokes handler and then triggers change detection.

This question is not about how to run handler outside Angular.

This question is about what if handler is in an external library I am consuming, and I want to prevent Angular to trigger change detection. Is there a way to opt out and if so how ?

  • try tp setup your listener in `runOutsideAngular` scope – enno.void Feb 09 '21 at 09:10
  • @enno.void I explicitely wrote the question is not about that. I do not have any control over the library. –  Feb 09 '21 at 09:21
  • I think run it outside of angular is the only way to prevent change detection in this case, because all events that har used within angular are hooked to zoneJS which triggers the change detection – enno.void Feb 09 '21 at 09:28

0 Answers0