I have the following code inside of a directive and I want to make sure it gets cleaned up when the scope is destroyed. I've looked online as well as the code and I was wondering how do I unbind an element.
var window = angular.element($window);
window.bind("resize", function(e){
abc();
});
Solution:
var abc = function() {};
var window = angular.element($window);
window.bind('resize', abc);
scope.$on('$destroy', function(e) {
window.unbind('resize', abc);
});