-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Back button Inconsistent behaviour - using location:replace #3014
Comments
I have a similar problem. I go from one state to another and when I go back by using browsers backbutton I either don't go anywhere or I go back in history, loosing som params in the url and can't forward to the state I was previously on. Can't share code, comapny secrets you know. |
Browser back button doesn't work for me either for some reason: the url changes correctly after the # however the view remains the same, there is no view transition to the correct component. I also noticed that navigating directly to a deep-link url doesn't navigate to the correct component but rather to the root component. I know the navigation's not happening because not only is the UI not correct, but also the component controllers are not instantiated. Any idea what I'm doing wrong? Note: different to the demos in the tutorial (https://ui-router.github.io/tutorial/ng1/hellogalaxy) I don't include the ui-srefs to components on the |
Found it: my state URLs weren't prefixed with |
This is due to the timing of The reason it works the first time is that loading the templates (via Your code works if you introduce a delay before processing the controller: function($scope,$state, $timeout) {
$timeout().then(() => $state.go("home.foo.bar",{},{location: 'replace'}))
}, Here's a working plunker: http://plnkr.co/edit/rcWRE6y785tbajP3uhdU?p=preview Note: in 1.0, the preferred mechanism is to use Here's a plunker demonstrating each approach:
The onEnter hook most closely resembles your controller based approach because it allows a parent state to be directly activated as long as a deeper state was already active. For example, it allows this: trans #1: home -> home.foo (redirects -> home.foo.bar -> home.foo.bar.boo) Where as the redirectTo hook always redirects of the state is about to be activated: trans #1: home -> home.foo (redirects -> home.foo.bar -> home.foo.bar.boo) I'm closing this bug as |
http://plnkr.co/edit/MbnFw7QzpoBuvJ2Perc5?p=preview
Steps to create:
I would expect the 'back' page to be Home each time, but only the first one goes to the home state. All subsequent 'backs' go to the Error page. It seems that the 'Home' state is removed from the history after the first back. I'm using location: replace to make all the child states go back to the Home state (seems the issue is here with the replace).
The text was updated successfully, but these errors were encountered: