2

When I use angularjs, lately I have gotten into the habit of taking advantage of the directive $destroy event, usually I do something like

$scope.$on('$destroy', function() {
  $element = null;
  $attrs = null;
  outOfScopeVariable = null;
});

My questions are,

  1. What's really necessary to do here?
  2. How does this work with transcluded directives?
  3. Best practices?
Sarjan Desai
  • 3,683
  • 2
  • 19
  • 32
z.a.
  • 2,549
  • 3
  • 12
  • 16
  • 2
    I do recommend to read up on this http://www.bennadel.com/blog/2706-always-trigger-the-destroy-event-before-removing-elements-in-angularjs-directives.htm – Pankaj Parkar Oct 20 '15 at 05:55
  • you may want to take a look at this too http://stackoverflow.com/questions/26983696/angularjs-does-destroy-remove-event-listeners – Gonzalo.- Oct 31 '15 at 20:25

0 Answers0