I want to destroy a token held in localStorage
whenever a my application is closed. Previously I would do something like this:
window.onbeforeunload = function (event) {
localStorage.removeItem('token');
};
I'm not sure how to get this functionality within Angular2 or where to put the code so that it executes whenever the application is closed. My instincts tell me to put it in my app level component, but I've failed at being able to google an answer.