christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

Controller reloaded when params in route #380

Open that1guy opened 5 years ago

that1guy commented 5 years ago

The initial transition to the sticky state works well, but when you transition away and then come back to the sticky state, the view reloads and the controller re-runs (thus losing any changes made on that scope/view). This issue only happens when $stateParams contains a javascript object.

See my plunk here: http://plnkr.co/edit/b9zpVyApL6tx2pe8XoZz?p=preview

(Initial state is app.survey)

1) Click on the Property Details Page tab 2) Click the Go back to app.survey on the property details page 3) Notice that the controller is reloaded

This issue is realted to https://github.com/christopherthielen/ui-router-extras/issues/239. but you fixed that scenario. I'm not sure what I'm doing differently to be reproducing this issue. I'm using the latest ui-router legacy and ui-router-extras

Thanks for help.

that1guy commented 5 years ago

@christopherthielen any chance you could help with this one real quick? Just point me in the right direction.

nmoinvaz commented 5 years ago

I discovered that this is happens when trying to navigate to the saved UI sticky state without the exact same params that are specified in .state(). In other words, if it detects that the stateParams have changed, it will reload. If upon initialization you create the state with certain parameters, the next time you navigate to it you should specify the exact same parameters.

Also in issue #273, there is an interest approach to prevent having to pass the same parameters each time, and that is to create an intermediate state.