angular directive to handle onbeforeunload events on angularJS pages