diff --git a/src/dropdown/dropdown.js b/src/dropdown/dropdown.js index fdb4e8b180..09282f3d49 100644 --- a/src/dropdown/dropdown.js +++ b/src/dropdown/dropdown.js @@ -230,9 +230,10 @@ angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position']) } }); - $scope.$on('$destroy', function() { + var offDestroy = $scope.$on('$destroy', function() { scope.$destroy(); }); + scope.$on('$destroy', offDestroy); }]) .directive('dropdown', function() { diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index 756367ae2d..7c45b1ad2a 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -89,9 +89,10 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position']) //create a child scope for the typeahead directive so we are not polluting original scope //with typeahead-specific data (matches, query etc.) var scope = originalScope.$new(); - originalScope.$on('$destroy', function() { - scope.$destroy(); + var offDestroy = originalScope.$on('$destroy', function(){ + scope.$destroy(); }); + scope.$on('$destroy', offDestroy); // WAI-ARIA var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);