-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
Project need an example for AngularJS directive memory leak with URL to live example on JSFiddle (or something like that)
For example there's a memory leak
function(scope, element, attrs) {
element.on('click', function() {
scope.selected = true
})
}And it could be fixed like the following:
function(scope, element, attrs) {
element.on('click', function() {
scope.selected = true
})
scope.$on('$destroy', function() {
element.off() // deregister all event handlers
})
}By the way for more information about memory leaks in AngularJS you could read here