Search code examples
angularjsangular-ui-routerangular-ui-router-extras

Angular ui-router-extras $previousState allways returning null


I'm using the angular-ui-router-extras module and more specifically the $previousState service, but I can't get it to return to the previous state, it always returns null.

This is all my code (the module is properly injected)

//When I enter the route I memorize the previous state
$previousState.memo('caller');

//more code

self.goBack = function () {
            $previousState.go('caller');
};

I inspected the $previousState object and it seems to have the proper methods and the error I get when I try to use $previousState.go() makes sense as I can't go to a null state.

What am I missing so that it should work ?


Solution

  • I'll close this as the null was valid, the issue arose because my users were deep-lining to the page and thus they had no previous state to memorise, if they go through the proper flow the $previousState has value.