Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
fix(uiLayout): remove event listeners from destroyed elements
Browse files Browse the repository at this point in the history
Removes the event listener for the window resize event when the element's scope is destroyed.
  • Loading branch information
jbro-io committed Nov 11, 2014
1 parent b8c0a3e commit 564d6fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ui-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,16 @@ angular.module('ui.layout', [])
ctrl.updateDisplay();
});

angular.element($window).bind('resize', function() {
function onResize() {
scope.$apply(function() {
ctrl.updateDisplay();
});
}

angular.element($window).bind('resize', onResize);

scope.$on('$destroy', function() {
angular.element($window).unbind('resize', onResize);
});
}
};
Expand Down

0 comments on commit 564d6fa

Please # to comment.