I’ve been trying to find an elegant way of dealing with events in AngularJS recently. If you’re not farmiliar with Angular, that’s ok, this is a pretty common pattern. Here I have a controller that registers an event listener: function MyController($rootScope) { $rootScope.$on('event1', () => { console.log('event 1 occured'); }); } There’s an issue with this code. It doesn’t unbind the listener when the controller (or its scope) is destroyed. Let’s take care of this.