I have a scenario where I have the following structure of nested states:
root root.item1 root.item2
In root state there is a template showing some variables set in child states. It should also be started first, because it has logic that determines which child state will be loaded.
In case root determines that root.item2 needs to be loaded, the flow of events:
exec root -> redirect to root.item2 -> exec root.item2
Now, if at that moment we are redirected to root.item1 and they click the "Back in browser" button, I expect it to be redirected to root.item2 , but instead it looks like the URL is just cleared and you donβt see no child state is loaded at all.
Here is an example plunger that shows the problem.
Steps to reproduce the problem in Plunker:
- Let it load
root.item2 - Click
Go to Detail 1 - Please note that you are on
root.item1 - Click "Back Browser"
- Please note that you are not on
root.item2
Submitted by Issue to the UI Router Gihub Page. Hope some help comes from there.
Any help is appreciated.
Code that shows the problem:
angular .module('historyApp', [ 'ui.router' ]) .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider .state('root', { url: '/', template: '<h1>Parent</h1> <div>{{vm.title}}</div> <div ui-view></div>', controller: function($scope, $state){ $scope.vm = { title: '' };
<!DOCTYPE html> <html ng-app="historyApp"> <head> <script src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script> <script src="https://rawgit.com/angular-ui/ui-router/0.2.10/release/angular-ui-router.js"></script> </head> <body> <div ui-view=""></div> </body> </html>
source share