This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Emitting an event on a destroyed scope #6768
Open
Description
Say you have the following code:
function Ctrl($scope) {
someService.call().then(function() {
$scope.$emit('some-event');
});
}
The promise might be resolved after the controller and the scope has been destroyed, which will emit the event into thin air since all listeners on the scope have been removed, and the connection to the parent scope is removed when the scope is destroyed.
The $emit
method should perhaps check this.$$destroyed
and throw an error in case it is destroyed?