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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -