AngularJS ui-route exit page : <p>I need a possibility to ask the user if he/she is leaving a page. 
I read that his would be a possibility but the event is fired when I enter the page and not when I leave the page.
<strong>onExit</strong> would work but this event I have to defined at the ... .routes.js and I need access to properties and functions at the controller.
Is there an event that is fired by exit of page?</p>

<pre><code>$scope.$on('$locationChangeStart', function( event ) {
        var answer = confirm("Are you sure you want to leave this page?")
        if (!answer) {
            event.preventDefault();
        }
    });
</code></pre>
