A simple AngularJS service for handling the 'OnBeforeUnload' event