ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

reload only certain ui-views when transitioning to same state consecutively

Open bbshopadmin opened this issue 13 years ago • 2 comments

Is following possible? I have two ui-views: "content" and "footer".

.state('root.content', {
                views: {
                    'content@': {
                        templateUrl: 'content.html',
                        controller: 'ContentController'
                    },
                    'footer@':{
                        templateUrl: 'footer.html',
                        controller: 'FooterController'
                    }
               params: ['somevar']
                }

I invoke the "root.content" state consecutively with different parameters so that it's reloaded everytime. Now i want only one of both ui-views to be reloaded everytime (content - reload every time) but not the other (footer - reload only once when footer template changes).

bbshopadmin avatar May 31 '13 14:05 bbshopadmin

Maybe use an abstract parent to set up the footer?

.state('root', {
    views: {
        'footer@': {
            templateUrl: 'footer.html',
            controller: 'FooterController'
        }
    }
})
.state('root.content', {
    views: {
        'content@': {
            templateUrl: 'content.html',
            controller: 'ContentController'
        }
    },
    params: ['somevar']
})

Now when you transitionTo root.content with a new param only that state will load, but not its parent. The parent is only loaded the first time you transitionTo root.content.

timkindberg avatar May 31 '13 15:05 timkindberg

Just what i wanted. Thank you!

bbshopadmin avatar May 31 '13 15:05 bbshopadmin