Skip to content

Changing state before previous state's "resolve" finishes causes previous state to still load #2266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jullian-chavez opened this issue Sep 24, 2015 · 2 comments

Comments

@jullian-chavez
Copy link

So we have a state that needs to resolve some data prior to the controller being initiated. So, we put the specific API query into that state's "resolve" attribute. However, this API query may take several seconds to complete (unfortunately). As a result, if a user clicks a link to another state BEFORE the other state's resolve completes, the user is taken to that page, but then when the previous state's "resolve" promise resolves, the previous template and controller still load. I would think that if you change states, any unresolved state would be canceled out, unless i'm missing something.

$stateProvider
     .state('learn',{
            url: '/learn/:slug',
            views: {
                'template':{
                    templateUrl: '/templates/pages/learn/index.html',
                    controller: 'LearnController',
                    resolve: {
                        currentCard: function($stateParams, CardsResource){
                            return CardsResource.get({slug: $stateParams.slug}); //This can take several seconds
                        }
                    }
                }
            }
        });

If a user clicks a link to another state while this resolve function's "CardsResource" API call is still waiting for a response, the new state will load, and then the state pasted above will load it's template and controller, breaking the page. Again, I would think that if a user changes state, this state's resolves would be canceled.

@jullian-chavez
Copy link
Author

Seems to already be acknowledged: #2126

@wesleycho
Copy link
Contributor

Closing as a duplicate ticket

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

No branches or pull requests

2 participants