-
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
Calling $state.go from parent state controller to current state causes URL to not be updated. #1583
Comments
Hello, I've got the same problem. I've got a parent view with 3 buttons linked to 3 children views. When i change views it works for 2 and changes the URL, but it won't change the url for the initial view. Is there more known about the solution for this problem ? |
I believe you can work around it by doing something like:
|
Same issue. Doing the above doesn't seem to do anything. |
I have the same issue and don't understand what is causing this, but I think it has something to do with angular's $location service that ui-router is using internally. As suggested in one issue in angular.js project (angular/angular.js#11075) I wrapped my $state.go('foo') call inside $timeout and now my URL gets updated as expected.
|
adding timeout fixed the url issue(it doesnt reset to the base url), but now browser back resets to base url instead of the correct one |
I was having the issue, updating to the latest version solved it. However, now I am having a different problem. The state does not transition to the state I specify, instead it goes to the first child state defined under an abstract state. Here is an example. I have the following states defined in my app: $stateProvider
.state('root', {
url: '/',
abstract: true,
template: '<ui-view></ui-view>',
controller: 'ApplicationController as application'
})
.state('root.index', {
url: '',
parent: 'root',
templateUrl: 'templates/index.html'
})
.state('root.splash', {
url: '',
parent: 'root',
templateUrl: 'templates/marketing/splash.html'
})
.state('join', {
url: '/join',
controller: 'RegistrationsController as newUserRegistration',
templateUrl: 'templates/marketing/join.html'
})
.state('login', {
url: '/login',
controller: 'SessionsController as newUserSession',
templateUrl: 'templates/marketing/login.html'
}) In my controller, I want to navigate to function createSession(user) {
if (user && user.email && user.password) {
$http.post('/login', {user: user}).success(function (user) {
setCurrentUser(user);
$state.go('root.index');
});
}
} The url updates correctly, however the state that gets loaded is |
I have the same problem hehe.. and it's a wizard steps use case as well 😃 |
This seems to have been fixed in 0.2.15. If this is still an issue for you, please open a new issue and provide a plunker. |
First, the Plunker.
I'm running into a small problem where calling
$state.go()
from a parent state controller, which may sometimes go to the current state, not updating the URL.The usage is for a multi-step wizard process, where I have each step as a separate state/view/controller, with a parent state/view/controller with some minimal logic. One thing it tries to do is redirect to the first step if somehow someone initially goes to the URL of an intermediate step:
In the case where the app is already transitioning from somewhere to
wizard.start
, the URL is not updated from where it was originally.In the Plunkr, if from any of the states, you click the link for
Bar One
, the location will not be updated.Any thoughts? Thanks!
The text was updated successfully, but these errors were encountered: