ui-router icon indicating copy to clipboard operation
ui-router copied to clipboard

How to Get A Route Parameter for Resolve ?

Open summer-liu opened this issue 11 years ago • 3 comments

I'm trying to get the route parameter for resolve, but $state.current.params, $state.params, $stateParams are all empty. But in ng-router, I can get it by using $route.current.params.

summer-liu avatar Apr 02 '15 10:04 summer-liu

+1

Morriz avatar Apr 13 '15 09:04 Morriz

At the point at which resolves are triggered, the global state hasn't been updated because the transition is pending and could still fail. If that happens, everything needs to be rolled back so that the UI is left in a consistent state.

Keep in mind, injecting $stateParams is 'magical', such that your resolves will only get the parameters for the state on which it is defined, as well as any parent states.

We're working on an API which will allow resolves to access all details of the transition, which is due out shortly. Stay tuned. In the meantime, I'd suggest posting a plunkr of your issue and taking it to StackOverflow, where the community can help you debug it. Thanks.

nateabele avatar Apr 14 '15 19:04 nateabele

+1

anasanzari avatar May 18 '18 18:05 anasanzari