javascript - How do you explicitly destroy a directive? -


in angular app, have directive. if remove 1 dom manipulation (e.g. jquery empty()), destroy event isn't called:

myapp.directive('joe', function() {     return {         restrict: 'e',         replace: true,         link: function(scope, element, attrs)         {                         element.html("hi !");              element.bind('$destroy', function()              {                 console.log("bye");             });         }     }; }); 

demo: http://jsfiddle.net/ymx4n/

furthermore, if remove & add lot of times directive empty() & appendto() , number of nodes always increase. means directives in memory, , garbage collector never remove these nodes.

maybe "normal" behavior, because angularjs can't know when remove/change dom nodes directly. however, possible destroy explicitly directive ? how add , remove directives dom manipulation, without kind of """memory leak""" ?

thanks !


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -