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

Angular Routers: Resolve on a stick state


My application has two views, each of these has two routes. When a user change the route of one view, the other should not be changed. This is achieved using sticky states.

One of the routes uses a resolve to go grab something from the server. In my application this is dependent on a route parameter which is simulated in the plunker I put together by returning a random number.

The issue is that the resolve only fires once which means, regardless of the route parameter, it ends up loading the same content and redirecting to the same URL every time.

Worse yet, adding {reload: true} to the state causes this error: state.params.$$keys is not a function. I've started reading the source but figured I should post here in case anyone had seen this before.

I would prefer not to refactor the app to avoid parallel states, and so would appreciate any other suggestions.


Solution

  • You are running into issue #112 https://github.com/christopherthielen/ui-router-extras/issues/112

    I built from source and updated your plunk and it seems to be working correclty now when transitioning back and forth between ViewB RouteA and Route B

    http://plnkr.co/edit/zpEXaJqXtJPH1pVKPVxj?p=preview

    Stupid stackoverflow requires me to add code to the answer since i linked to a forked plunk.  there's no code to add