title: Detecting page unload in angularjs
body: <p>I have a javascript object which I need global to my angularjs application. When the application is about to be unloaded (due to a page refresh or some other scenario), I would like to persist the object to browser storage. I believe adding the object to $rootScope would fulfill the first requirement of making the object global, but writing the object to storage during the <code>onbeforeunload</code> event, would require access to the $rootScope variable. Is it possible to detect a page unload event in angularjs?</p>