0

I have event listeners activated by:

var unregisterSubscription = $rootScope.$on(event, handler);

The event is activated in component and/or directive. I want the listener to listen when the user uses the scope of the listener, otherwise not.

now my question is where i activate the unregisterSubscription method?

Zakk
  • 758
  • 3
  • 11
  • 20

1 Answers1

0

You can create destroy event in controller.

$rootScope.$on('$destroy', function() {
    unregisterSubscription(); // Call unregisterSubscription method.
});