angularjs - I want to execute a function before controller destruction -
in application have simple angularjs controller, want warn user before destruction of scope. have idea of how doing ?
app.controller('myctrl',["$scope", function($scope) { $scope.myvariabl = "test"; }]);
the $destroy
event:
$scope.$on('$destroy', function() { ... });
look here, near end, section "events".
i doubt can warn user in function though. you'd better catch event destroys scope (clicking button?), ask user there and, if user agrees, proceed destruction of scope.
Comments
Post a Comment