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
How to pass custom data in $state.go() in angular-ui-router? #1949
Comments
$stateProvider.state('users', {
url: '/users',
controller: 'UsersCtrl',
params: {
obj: null
}
}) function UserCtrl($stateParams) {
console.log($stateParams);
} $state.go('users', {obj:yourObj}); |
Sorry but this approach produces the following error:
|
@victorwoo that message comes from versions of ui-router |
Yes, it works after upgrading to |
@zhdanovartur @christopherthielen, Thanks a lot !!!!!!. It also solved my problem which i am stuck for half an hour. |
@zhdanovartur Thanks fam, you just saved me a headache. |
+1 to @zhdanovartur even though it is kind of a weird solution. |
@zhdanovartur @christopherthielen, Thanks a lot..!!! It is really helpful. |
@zhdanovartur what should i do?! |
Funcionou demais :D |
The values are changing on page refresh. How to prevent that? |
@zhdanovartur Thank you !!! |
@zhdanovartur works but re correct conrole.log($stateParams); |
@MoatazGitHub fixed, thanks) |
$http.get('js/mockData.json') i am having issue with the above code, |
@jijishthomas when you change the state, the $scope will change. you need to pass the data to the route and get it in the new route from $stateParams |
@zhdanovartur $stateParams is deprecated. |
@viT-1 Exactly the same. |
I want to pass a custom object to another state via
$state.go()
in UI-Router.But I need to run
fun()
in target state, so I can't pass this object in URL parameter. In target controller, I tried to fetch the value ofobj
via$stateParams
but got empty object{}
:So how to pass
obj
to state "users" correctly?The text was updated successfully, but these errors were encountered: