1

If I bootstrap an AngularJS app on a DOM node, then delete the DOM node via the raw DOM API, will the object graph backing the AngularJS app be collected?

If so, how does the browser know to do this? Is it because the DOM node dominates the memory associated with the JS object graph of the application.

Ben Aston
  • 53,718
  • 65
  • 205
  • 331
  • You might have to call `$scope.$digest()` Check this out: http://stackoverflow.com/a/11873839/749232 ? – saji89 Jun 09 '16 at 08:25
  • Be careful deleting directives outside of Angular. That's how you get memory leaks as your `$scope` will remain. You should delete your scope using `$scope.$destroy()`. If you mustdo it outside of angular listen to an even on the native DOM element then when it fires delete your directive in the angular domain. [this blog](http://www.bennadel.com/blog/2706-always-trigger-the-destroy-event-before-removing-elements-in-angularjs-directives.htm), and [this SO](http://stackoverflow.com/questions/26983696/angularjs-does-destroy-remove-event-listeners) will help. Search $destory on the directive docs – ste2425 Jun 09 '16 at 08:41
  • Just realised you meant the node the whole app is on, not a directive. My bad, its too late to edit my comment now. – ste2425 Jun 09 '16 at 08:51
  • hello @Ben have you solve this problem , i am on same situations – Amit Singh Rawat Jun 26 '18 at 10:14

0 Answers0