Optimizing Events handling in Angular

added by JavaScript Kicks
8/5/2019 7:39:11 AM

1309 Views

Angular provides a handy declarative way to subscribe to an even inside a template using (eventName)="onEventName($event)" syntax. Combine that with ChangeDetectionStrategy.OnPush and you get change detection cycles ran only on events we are interested in. In other words, if we listen to (input) event on an element - we are not going to have change detection ran if user simply clicks on it.


0 comments