Check out my issue in action with this plunkr demo. The problem I'm encountering is quite straightforward: manually calling $destroy or removing the element does not trigger the $destroy event.
function link(scope, element, attrs) {
// Manually calling scope $destroy, however the event is not fired
scope.$destroy();
// Removing the element also does not trigger $destroy
element.remove()
scope.$on("$destroy", function handleDestroy() {
console.log("I am destroyed")
})
}
After reading this answer, I am even more puzzled. If element
also receives a $destroy event, why do people unbind events at scope
$destroy rather than element
$destroy?