Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
fix: properly gc on destruction
Browse files Browse the repository at this point in the history
- Properly garbage collect resize handler when directive is destroyed
- Properly debounce callback
  • Loading branch information
wesleycho committed Mar 30, 2016
1 parent a4a010d commit 95692e7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,14 @@ uis.controller('uiSelectCtrl',
}
}

var onResize = $$uisDebounce(function() {
ctrl.sizeSearchInput();
}, 50);

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

$scope.$on('$destroy', function() {
ctrl.searchInput.off('keyup keydown tagged blur paste');
angular.element($window).off('resize', onResize);
});

angular.element($window).bind('resize', $$uisDebounce(function() {
ctrl.sizeSearchInput();
}), 50);

}]);

0 comments on commit 95692e7

Please sign in to comment.