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

fix issue 4298: Parent context keeps a reference on destroyed childre… #4299

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/dropdown/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 3 additions & 2 deletions src/typeahead/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down