recently I run into a problem with $stateChangeStart event, when I implemented the authentication in my app. I restricted access to some pages with boolean value like this:
.state('login', {
url:'/login',
templateUrl: 'modules/authentication/views/login.html',
controller: 'LoginController',
data: {
requireAuthentication: false
}
})
and I want to check, if there are any authentication data and if the user accesses a route with requireAuthentication: true he is automatically redirected to the login page. So, that is a standard authentication behaviour.
During the implementation I got Maximum call stack size exceeded error. I spent four night hours on finding what is wrong with those ~10 lines of code.
I will post an answer with my working solution for those, who will probably look after a working solution (as me). I think that is importaint for other members.