How to stop unload if some data changed and I have to do something before. I'm trying this, but no effect
$scope.changed = true;
$scope.$on('$destroy', function () {
if ($scope.changed) {
alert('Let me clean up first !');
return ;
}
});