ui-router: Refreshing the browser doesn't refresh the ui-router's state when doing nested states.
In a situation like:
.state(
'blog',
{
abstract: true, //this state is abstract, it provides an abstract base for children (only abstract states can have a default child state)
url: '/blog',
templateUrl: 'blog.html',
controller: 'BlogCtrl'
}
)
.state(
'blog.posts',
{
url: '', //empty url demonstrates that it is the default childstate of the ui-view
templateUrl: 'blog_posts.html',
controller: 'BlogPostsCtrl'
}
)
.state(
'blog.post',
{
url: '/:blogPostId',
views: {
'': {
templateUrl: 'blog_post.html',
controller: 'BlogPostCtrl'
},
'comments': {
templateUrl: 'blog_post_comments.html',
controller: 'BlogPostCommentsCtrl'
}
}
}
);
When you go into e.com/blog/123 and go back to e.com/blog by refreshing the browser or a location refresh, it doesn’t change the state back to blog.posts. It does do it when I use the back button or hit on a link that changes the url, but a direct location refresh doesn’t.
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 32 (3 by maintainers)
@bikashsharmabks: Where do you add this code to avoid browser refresh taking to home page.
angular.module(‘app’).run([‘$state’, ‘$stateParams’, function($state, $stateParams) { //this solves page refresh and getting back to state }]);