How can I transfer data between states without changing URL?

How can I transfer data between states without changing URL? Does any one have a solution or tutorial. Thank you in advance!

Put the data in a service to share it between states

Thanks for your reply. I’ll try your solution.

If you do not know services read the angularjs doc or other tutorials about it.

No need a service,
you just have to use it right.

.state('whatever', {
	params: {
	    firstParam: {  },
	    secondParam: { }

@saltatempo,Thank you for your reply, cause I am new guy in this field, I can’t find how to use this code snippet. Can I use below code to transfer the data to ‘whatever’ page And what code should I fill in the object firstParam{} and secondParam{} in the .state() block?


if you use state-params the url is changing.

you can the define the state also in this way:

.state('whatever', {
   url: '/myItems/:parameter1',
   controller: '.....',

and you can navigate to it like:
$state.go(‘whatever’, { ‘parameter1’: 1 });

it is there for short parameters like if you have a detail state for a list and want to get the item by the id from the url.

It depends on what you want to do.
If you want to share whole object, arrays, long text you should use services

I want to use a non-URL change way to transfer the data, I find some solutions like @saltatempo’s, But just don’t understand why I got a undefined everytime. I think this @saltatempo’s direction must be right but I need some guidelines.