https://docs.angularjs.org/guide/directive

By listening to this event, you can remove event listeners that might cause 
>> memory leaks. Listeners registered to scopes and elements are automatically 
>> cleaned up when they are destroyed, but if you registered a listener on a 
>> service, or registered a listener on a DOM node that isn't being deleted, 
>> you'll have to clean it up yourself or you risk introducing a memory leak.
>
>
>> Best Practice: Directives should clean up after themselves. You can use 
>> element.on('$destroy', ...) or scope.$on('$destroy', ...) to run a clean-up 
>> function when the directive is removed.
>
>
 Questions, please:

I have a element.on "click", (event) -> inside my directive:


   1. When the directive is destroyed, are there any memory references to 
   the element.on to keep it from being garbage collected?
   2. Angular documentation states that I should use a handler to remove 
   event listeners on the $destroy emitted event. I was under the impression 
   that destroy() removed event listeners, is this not the case?
   

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to