I am facing this problem of passing data between two states without exposing the data in the url, it's like user cannot really directly land on this state.
For example. I have two states "A" and "B". I am doing some server call in state "A" and passing the response of the call to state "B". The response of the server call is a string message, which is quite long, so i cannot expose that in the url.
So is there any way in angular ui router to pass data between states, without using url params ?
The params object is included in $stateParams, but won't be part of the url.
1) In the route configuration:
2) In the controller:
3A) Changing the State from a controller
3B) Changing the State in html
Example Plunker
We can use
params
, new feature of the UI-Router:API Reference / ui.router.state / $stateProvider
See the part: "...or defines additional non-url parameters..."
So the state def would be:
Few examples form the doc mentioned above:
EXTEND - working example: http://plnkr.co/edit/inFhDmP42AQyeUBmyIVl?p=info
Here is an example of a state definition:
This could be a call using ui-sref:
Check the example here