$stateChangeStart not firing

Hello everybody,

I am using $rootScope.$on("$stateChangeStart", …) in my run function to check for authentication. It does work within the browser but doesn’t neither in Android nor the iOS emulator.

Any ideas for this?

Or how else could I achieve an auth check before certain views without running it manually each time within the controller?

Many thanks,


1 Like

Just figured out that I was cooling it inside the ionicPlatform.ready callback, which obviously didn’t work. Fixed now :wink:

1 Like

Glad to hear you got this resolved :thumbsup:

@p6n could you post your solution? I’m having a similar issue where when the app is first loaded on a real device, the $stateChangeStart event is not firing until after the first route change. However in the browser, when it first initializes, the event does fire.

I have the same problem @seanhill. $stateChangeStart is not fired the first time. @mhartington

app/home > not fired -> app/page1 > fired > app/home

UI-Router problem?

I’m seeing the same issue as danicomas where the $stateChangeStart event is not firing on first load but is firing on navigation to another tab or view.

Any ideas?


This solved the issue for me. I added it right at the top of the .run function:

.run(function ($ionicPlatform, $rootScope) {
        function(event, toState, toParams, fromState, fromParams){

        function(event, viewConfig){

    $rootScope.$on('$locationChangeStart', function(event, next, current) {
1 Like

Adding some callback functions and console logs solved the issue? @ArcReaction I don’t understand it :smiley:

Just like @p6n, I had the $stateChangeStart inside the ionicPlatform.ready callback, which didn’t get fired on first load. When I took it out of the ionicPlatform.ready callback, and put it right in the .run function, $stateChangeStart does get fired on first load. The console.log(s) are just there to show that the event gets fired.

thank you, that helped