Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

Sticky state's view/ctrl is being reloaded when passing an object on $stateParams via the 'params' property #239

Closed
aaronpikkarainen opened this issue Sep 4, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@aaronpikkarainen
Copy link

Greetings,

I've come across an issue when using sticky states (with deep state redirect) and passing objects as state parameters via the 'params' property of a state. 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. Using only primitive params on the URL works fine, but there are cases when we need to pass complex objects to a state.

I took the Simple Sticky States Example (http://plnkr.co/edit/bFMLqLENmPFfCD0XCz8V?p=info) and made three small changes to it to demonstrate the issue. See my fork here...

http://plnkr.co/edit/0Zgn7IxvNDsT5kgcRjDO?p=info

You will see the issue when you follow these steps:

(Initial state is tabs.account.stuff)

  • Enter text into the input box underneath "Here's my stuff"
  • Click on the 'Survey' tab
  • Click back to the 'Account' tab, which goes back to stuff because of DSR
    (the input becomes empty because the view and controller get reloaded even though it's part of a sticky/dsr group of states)

My plunker changed the following three lines of code...

  • script.js - line 7
    image
  • script.js - lines 31 & 32
    image

Thanks!

@aaronpikkarainen
Copy link
Author

Actually, this may not be a good example because the savedSurvey state param will be a different object when coming to the state a second time (thus a reload should probably happen). I used this example for the sake of simplicity, but my actual example gets back to the sticky state via deep state redirect. I can try to modify the example.

@aaronpikkarainen
Copy link
Author

I've now updated this issue and my plunker to be a better example using deep state redirect to return to the tabs.account.stuff state.

@christopherthielen
Copy link
Owner

confirmed, yes this is a bug. sticky states does not understand typed parameters properly.

@christopherthielen
Copy link
Owner

Added UI-Router Extras v0.0.15-pre2 to your plunk
http://plnkr.co/edit/2iAiamSWTi3Lh5PI7xHf?p=preview

@aaronpikkarainen
Copy link
Author

Thanks so much! The UI Router continues to prove amazing. Your team is much appreciated :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants