uksz uksz - 6 months ago 50
AngularJS Question

Angular UI Router: How to go to the same state with different $stateParam?

I am wondering how can I go to the same state, with different

$stateParam
?

I was trying to go with:

$state.go('^.currentState({param: 0})')


However, it was not working.

Answer

the params are second paramater of the go() method

$state.go('^.currentState', {param: 0})

go(to, params, options)

Convenience method for transitioning to a new state. $state.go calls $state.transitionTo internally but automatically sets options to { location: true, inherit: true, relative: $state.$current, notify: true }. This allows you to easily use an absolute or relative to path and specify only the parameters you'd like to update (while letting unspecified parameters inherit from the currently active ancestor states).