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

Back to a sticky state with params changed not working #112

Closed
molog opened this issue Dec 3, 2014 · 5 comments
Closed

Back to a sticky state with params changed not working #112

molog opened this issue Dec 3, 2014 · 5 comments
Assignees
Milestone

Comments

@molog
Copy link

molog commented Dec 3, 2014

Example steps:

  1. User is at the state /books/1
  2. User go to state /photos/1
  3. User go to state /books/2
  4. The page displays content about /books/1 instead of /books/2
    It seems params are not regarded as part of a state.
    I am not sure if this is intended. Is there a way to make above work so that it displays /books/2 ?
@christopherthielen
Copy link
Owner

I think that should work. Can you put it in a plunkr for me?

@christopherthielen christopherthielen self-assigned this Dec 3, 2014
@molog
Copy link
Author

molog commented Dec 4, 2014

http://plnkr.co/edit/Gy3ltQM7NLKKQAQslRkF?p=preview
if you click a book under the 'Books' tab and go to 'favorites' tab and click another book, you will see it goes back to the first book.

@BasitAli
Copy link

BasitAli commented Dec 4, 2014

Hi guys.

I just noticed this behaviour in my app after updating both ui-router and ui-router-extras. I jumped in the ct-ui-router-extras.js and tracked the issue down to this,

      // Duplicates logic in $state.transitionTo, primarily to find the pivot state (i.e., the "keep" value)
      function equalForKeys(a, b, keys) {
        if (!keys) {
          keys = [];
          for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility
        }

        for (var i = 0; i < keys.length; i++) {
          var k = keys[i];
          if (a[k] != b[k]) return false; // Not '===', values aren't necessarily normalized
        }
        return true;
      }

'keys' is an Object and it fails getting the ".length", thus returning true. Adding

keys = Object.keys(keys)

works for now.

@christopherthielen
Copy link
Owner

@molog @BasitAli Thanks for the plunk and the analysis.

I updated your plunk with 0.0.12-prerelease http://plnkr.co/edit/YtIbH7emVB4h6YyiMTlT?p=preview

@astyfx
Copy link

astyfx commented Jan 23, 2015

+1

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

No branches or pull requests

4 participants