Reputation: 67888
How do I persist query parameters through each state? For example, let's say a user tries to access to link, but needs to login first before they could get back to that page, so how can I route the user back to the page as well as keep all the query parameters? I spent a few hours trying to figure this out, but couldn't get it to work.
I have looked briefly into UrlMatcher and am unclear if that is what I need given that the documentation is lacking. I tried passing the url params with transitionTo which isn't a great solution because I would have to duplicate support across all states.
Upvotes: 0
Views: 842
Reputation: 4471
i think you may use the state inheritance, specify an abstact root state, config some share data, or you can use it to store query params, see this
Upvotes: 1
Reputation: 9392
You can get the data of both states like this.
$rootScope.$on('$stateChangeStart', function(event, toState, toParameters, fromState, fromParameters) {
//You can also see the complete url of the previous state.
console.log(fromState.url);
})
with both parameters and url of the starting state I think you can solve your problem.
Upvotes: 1